Clone of mesa.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

dri_interface.h 48KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465
  1. /*
  2. * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
  3. * Copyright 2007-2008 Red Hat, Inc.
  4. * (C) Copyright IBM Corporation 2004
  5. * All Rights Reserved.
  6. *
  7. * Permission is hereby granted, free of charge, to any person obtaining a
  8. * copy of this software and associated documentation files (the "Software"),
  9. * to deal in the Software without restriction, including without limitation
  10. * on the rights to use, copy, modify, merge, publish, distribute, sub
  11. * license, and/or sell copies of the Software, and to permit persons to whom
  12. * the Software is furnished to do so, subject to the following conditions:
  13. *
  14. * The above copyright notice and this permission notice (including the next
  15. * paragraph) shall be included in all copies or substantial portions of the
  16. * Software.
  17. *
  18. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
  19. * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  20. * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
  21. * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
  22. * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
  23. * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
  24. * USE OR OTHER DEALINGS IN THE SOFTWARE.
  25. */
  26. /**
  27. * \file dri_interface.h
  28. *
  29. * This file contains all the types and functions that define the interface
  30. * between a DRI driver and driver loader. Currently, the most common driver
  31. * loader is the XFree86 libGL.so. However, other loaders do exist, and in
  32. * the future the server-side libglx.a will also be a loader.
  33. *
  34. * \author Kevin E. Martin <kevin@precisioninsight.com>
  35. * \author Ian Romanick <idr@us.ibm.com>
  36. * \author Kristian Høgsberg <krh@redhat.com>
  37. */
  38. #ifndef DRI_INTERFACE_H
  39. #define DRI_INTERFACE_H
  40. /* For archs with no drm.h */
  41. #if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__)
  42. #ifndef __NOT_HAVE_DRM_H
  43. #define __NOT_HAVE_DRM_H
  44. #endif
  45. #endif
  46. #ifndef __NOT_HAVE_DRM_H
  47. #include <drm.h>
  48. #else
  49. typedef unsigned int drm_context_t;
  50. typedef unsigned int drm_drawable_t;
  51. typedef struct drm_clip_rect drm_clip_rect_t;
  52. #endif
  53. /**
  54. * \name DRI interface structures
  55. *
  56. * The following structures define the interface between the GLX client
  57. * side library and the DRI (direct rendering infrastructure).
  58. */
  59. /*@{*/
  60. typedef struct __DRIdisplayRec __DRIdisplay;
  61. typedef struct __DRIscreenRec __DRIscreen;
  62. typedef struct __DRIcontextRec __DRIcontext;
  63. typedef struct __DRIdrawableRec __DRIdrawable;
  64. typedef struct __DRIconfigRec __DRIconfig;
  65. typedef struct __DRIframebufferRec __DRIframebuffer;
  66. typedef struct __DRIversionRec __DRIversion;
  67. typedef struct __DRIcoreExtensionRec __DRIcoreExtension;
  68. typedef struct __DRIextensionRec __DRIextension;
  69. typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
  70. typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
  71. typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
  72. typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
  73. typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
  74. typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;
  75. typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;
  76. typedef struct __DRIswrastExtensionRec __DRIswrastExtension;
  77. typedef struct __DRIbufferRec __DRIbuffer;
  78. typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;
  79. typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;
  80. typedef struct __DRI2flushExtensionRec __DRI2flushExtension;
  81. typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension;
  82. typedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension;
  83. typedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension;
  84. /*@}*/
  85. /**
  86. * Extension struct. Drivers 'inherit' from this struct by embedding
  87. * it as the first element in the extension struct.
  88. *
  89. * We never break API in for a DRI extension. If we need to change
  90. * the way things work in a non-backwards compatible manner, we
  91. * introduce a new extension. During a transition period, we can
  92. * leave both the old and the new extension in the driver, which
  93. * allows us to move to the new interface without having to update the
  94. * loader(s) in lock step.
  95. *
  96. * However, we can add entry points to an extension over time as long
  97. * as we don't break the old ones. As we add entry points to an
  98. * extension, we increase the version number. The corresponding
  99. * #define can be used to guard code that accesses the new entry
  100. * points at compile time and the version field in the extension
  101. * struct can be used at run-time to determine how to use the
  102. * extension.
  103. */
  104. struct __DRIextensionRec {
  105. const char *name;
  106. int version;
  107. };
  108. /**
  109. * The first set of extension are the screen extensions, returned by
  110. * __DRIcore::getExtensions(). This entry point will return a list of
  111. * extensions and the loader can use the ones it knows about by
  112. * casting them to more specific extensions and advertising any GLX
  113. * extensions the DRI extensions enables.
  114. */
  115. /**
  116. * Used by drivers to indicate support for setting the read drawable.
  117. */
  118. #define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
  119. #define __DRI_READ_DRAWABLE_VERSION 1
  120. /**
  121. * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
  122. */
  123. #define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
  124. #define __DRI_COPY_SUB_BUFFER_VERSION 1
  125. struct __DRIcopySubBufferExtensionRec {
  126. __DRIextension base;
  127. void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);
  128. };
  129. /**
  130. * Used by drivers that implement the GLX_SGI_swap_control or
  131. * GLX_MESA_swap_control extension.
  132. */
  133. #define __DRI_SWAP_CONTROL "DRI_SwapControl"
  134. #define __DRI_SWAP_CONTROL_VERSION 1
  135. struct __DRIswapControlExtensionRec {
  136. __DRIextension base;
  137. void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
  138. unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
  139. };
  140. /**
  141. * Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
  142. */
  143. #define __DRI_FRAME_TRACKING "DRI_FrameTracking"
  144. #define __DRI_FRAME_TRACKING_VERSION 1
  145. struct __DRIframeTrackingExtensionRec {
  146. __DRIextension base;
  147. /**
  148. * Enable or disable frame usage tracking.
  149. *
  150. * \since Internal API version 20030317.
  151. */
  152. int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable);
  153. /**
  154. * Retrieve frame usage information.
  155. *
  156. * \since Internal API version 20030317.
  157. */
  158. int (*queryFrameTracking)(__DRIdrawable *drawable,
  159. int64_t * sbc, int64_t * missedFrames,
  160. float * lastMissedUsage, float * usage);
  161. };
  162. /**
  163. * Used by drivers that implement the GLX_SGI_video_sync extension.
  164. */
  165. #define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
  166. #define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
  167. struct __DRImediaStreamCounterExtensionRec {
  168. __DRIextension base;
  169. /**
  170. * Wait for the MSC to equal target_msc, or, if that has already passed,
  171. * the next time (MSC % divisor) is equal to remainder. If divisor is
  172. * zero, the function will return as soon as MSC is greater than or equal
  173. * to target_msc.
  174. */
  175. int (*waitForMSC)(__DRIdrawable *drawable,
  176. int64_t target_msc, int64_t divisor, int64_t remainder,
  177. int64_t * msc, int64_t * sbc);
  178. /**
  179. * Get the number of vertical refreshes since some point in time before
  180. * this function was first called (i.e., system start up).
  181. */
  182. int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
  183. int64_t *msc);
  184. };
  185. #define __DRI_TEX_OFFSET "DRI_TexOffset"
  186. #define __DRI_TEX_OFFSET_VERSION 1
  187. struct __DRItexOffsetExtensionRec {
  188. __DRIextension base;
  189. /**
  190. * Method to override base texture image with a driver specific 'offset'.
  191. * The depth passed in allows e.g. to ignore the alpha channel of texture
  192. * images where the non-alpha components don't occupy a whole texel.
  193. *
  194. * For GLX_EXT_texture_from_pixmap with AIGLX.
  195. */
  196. void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
  197. unsigned long long offset, GLint depth, GLuint pitch);
  198. };
  199. /* Valid values for format in the setTexBuffer2 function below. These
  200. * values match the GLX tokens for compatibility reasons, but we
  201. * define them here since the DRI interface can't depend on GLX. */
  202. #define __DRI_TEXTURE_FORMAT_NONE 0x20D8
  203. #define __DRI_TEXTURE_FORMAT_RGB 0x20D9
  204. #define __DRI_TEXTURE_FORMAT_RGBA 0x20DA
  205. #define __DRI_TEX_BUFFER "DRI_TexBuffer"
  206. #define __DRI_TEX_BUFFER_VERSION 3
  207. struct __DRItexBufferExtensionRec {
  208. __DRIextension base;
  209. /**
  210. * Method to override base texture image with the contents of a
  211. * __DRIdrawable.
  212. *
  213. * For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of
  214. * setTexBuffer2 in version 2 of this interface
  215. */
  216. void (*setTexBuffer)(__DRIcontext *pDRICtx,
  217. GLint target,
  218. __DRIdrawable *pDraw);
  219. /**
  220. * Method to override base texture image with the contents of a
  221. * __DRIdrawable, including the required texture format attribute.
  222. *
  223. * For GLX_EXT_texture_from_pixmap with AIGLX.
  224. *
  225. * \since 2
  226. */
  227. void (*setTexBuffer2)(__DRIcontext *pDRICtx,
  228. GLint target,
  229. GLint format,
  230. __DRIdrawable *pDraw);
  231. /**
  232. * Method to release texture buffer in case some special platform
  233. * need this.
  234. *
  235. * For GLX_EXT_texture_from_pixmap with AIGLX.
  236. *
  237. * \since 3
  238. */
  239. void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
  240. GLint target,
  241. __DRIdrawable *pDraw);
  242. };
  243. /**
  244. * Used by drivers that implement DRI2
  245. */
  246. #define __DRI2_FLUSH "DRI2_Flush"
  247. #define __DRI2_FLUSH_VERSION 4
  248. #define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
  249. #define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */
  250. #define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2)
  251. enum __DRI2throttleReason {
  252. __DRI2_THROTTLE_SWAPBUFFER,
  253. __DRI2_THROTTLE_COPYSUBBUFFER,
  254. __DRI2_THROTTLE_FLUSHFRONT
  255. };
  256. struct __DRI2flushExtensionRec {
  257. __DRIextension base;
  258. void (*flush)(__DRIdrawable *drawable);
  259. /**
  260. * Ask the driver to call getBuffers/getBuffersWithFormat before
  261. * it starts rendering again.
  262. *
  263. * \param drawable the drawable to invalidate
  264. *
  265. * \since 3
  266. */
  267. void (*invalidate)(__DRIdrawable *drawable);
  268. /**
  269. * This function reduces the number of flushes in the driver by combining
  270. * several operations into one call.
  271. *
  272. * It can:
  273. * - throttle
  274. * - flush a drawable
  275. * - flush a context
  276. *
  277. * \param context the context
  278. * \param drawable the drawable to flush
  279. * \param flags a combination of _DRI2_FLUSH_xxx flags
  280. * \param throttle_reason the reason for throttling, 0 = no throttling
  281. *
  282. * \since 4
  283. */
  284. void (*flush_with_flags)(__DRIcontext *ctx,
  285. __DRIdrawable *drawable,
  286. unsigned flags,
  287. enum __DRI2throttleReason throttle_reason);
  288. };
  289. /**
  290. * Extension that the driver uses to request
  291. * throttle callbacks.
  292. */
  293. #define __DRI2_THROTTLE "DRI2_Throttle"
  294. #define __DRI2_THROTTLE_VERSION 1
  295. struct __DRI2throttleExtensionRec {
  296. __DRIextension base;
  297. void (*throttle)(__DRIcontext *ctx,
  298. __DRIdrawable *drawable,
  299. enum __DRI2throttleReason reason);
  300. };
  301. /*@}*/
  302. /**
  303. * The following extensions describe loader features that the DRI
  304. * driver can make use of. Some of these are mandatory, such as the
  305. * getDrawableInfo extension for DRI and the DRI Loader extensions for
  306. * DRI2, while others are optional, and if present allow the driver to
  307. * expose certain features. The loader pass in a NULL terminated
  308. * array of these extensions to the driver in the createNewScreen
  309. * constructor.
  310. */
  311. typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
  312. typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
  313. typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
  314. typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
  315. typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
  316. /**
  317. * Callback to getDrawableInfo protocol
  318. */
  319. #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
  320. #define __DRI_GET_DRAWABLE_INFO_VERSION 1
  321. struct __DRIgetDrawableInfoExtensionRec {
  322. __DRIextension base;
  323. /**
  324. * This function is used to get information about the position, size, and
  325. * clip rects of a drawable.
  326. */
  327. GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
  328. unsigned int * index, unsigned int * stamp,
  329. int * x, int * y, int * width, int * height,
  330. int * numClipRects, drm_clip_rect_t ** pClipRects,
  331. int * backX, int * backY,
  332. int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
  333. void *loaderPrivate);
  334. };
  335. /**
  336. * Callback to get system time for media stream counter extensions.
  337. */
  338. #define __DRI_SYSTEM_TIME "DRI_SystemTime"
  339. #define __DRI_SYSTEM_TIME_VERSION 1
  340. struct __DRIsystemTimeExtensionRec {
  341. __DRIextension base;
  342. /**
  343. * Get the 64-bit unadjusted system time (UST).
  344. */
  345. int (*getUST)(int64_t * ust);
  346. /**
  347. * Get the media stream counter (MSC) rate.
  348. *
  349. * Matching the definition in GLX_OML_sync_control, this function returns
  350. * the rate of the "media stream counter". In practical terms, this is
  351. * the frame refresh rate of the display.
  352. */
  353. GLboolean (*getMSCRate)(__DRIdrawable *draw,
  354. int32_t * numerator, int32_t * denominator,
  355. void *loaderPrivate);
  356. };
  357. /**
  358. * Damage reporting
  359. */
  360. #define __DRI_DAMAGE "DRI_Damage"
  361. #define __DRI_DAMAGE_VERSION 1
  362. struct __DRIdamageExtensionRec {
  363. __DRIextension base;
  364. /**
  365. * Reports areas of the given drawable which have been modified by the
  366. * driver.
  367. *
  368. * \param drawable which the drawing was done to.
  369. * \param rects rectangles affected, with the drawable origin as the
  370. * origin.
  371. * \param x X offset of the drawable within the screen (used in the
  372. * front_buffer case)
  373. * \param y Y offset of the drawable within the screen.
  374. * \param front_buffer boolean flag for whether the drawing to the
  375. * drawable was actually done directly to the front buffer (instead
  376. * of backing storage, for example)
  377. * \param loaderPrivate the data passed in at createNewDrawable time
  378. */
  379. void (*reportDamage)(__DRIdrawable *draw,
  380. int x, int y,
  381. drm_clip_rect_t *rects, int num_rects,
  382. GLboolean front_buffer,
  383. void *loaderPrivate);
  384. };
  385. #define __DRI_SWRAST_IMAGE_OP_DRAW 1
  386. #define __DRI_SWRAST_IMAGE_OP_CLEAR 2
  387. #define __DRI_SWRAST_IMAGE_OP_SWAP 3
  388. /**
  389. * SWRast Loader extension.
  390. */
  391. #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
  392. #define __DRI_SWRAST_LOADER_VERSION 2
  393. struct __DRIswrastLoaderExtensionRec {
  394. __DRIextension base;
  395. /*
  396. * Drawable position and size
  397. */
  398. void (*getDrawableInfo)(__DRIdrawable *drawable,
  399. int *x, int *y, int *width, int *height,
  400. void *loaderPrivate);
  401. /**
  402. * Put image to drawable
  403. */
  404. void (*putImage)(__DRIdrawable *drawable, int op,
  405. int x, int y, int width, int height,
  406. char *data, void *loaderPrivate);
  407. /**
  408. * Get image from readable
  409. */
  410. void (*getImage)(__DRIdrawable *readable,
  411. int x, int y, int width, int height,
  412. char *data, void *loaderPrivate);
  413. /**
  414. * Put image to drawable
  415. *
  416. * \since 2
  417. */
  418. void (*putImage2)(__DRIdrawable *drawable, int op,
  419. int x, int y, int width, int height, int stride,
  420. char *data, void *loaderPrivate);
  421. };
  422. /**
  423. * Invalidate loader extension. The presence of this extension
  424. * indicates to the DRI driver that the loader will call invalidate in
  425. * the __DRI2_FLUSH extension, whenever the needs to query for new
  426. * buffers. This means that the DRI driver can drop the polling in
  427. * glViewport().
  428. *
  429. * The extension doesn't provide any functionality, it's only use to
  430. * indicate to the driver that it can use the new semantics. A DRI
  431. * driver can use this to switch between the different semantics or
  432. * just refuse to initialize if this extension isn't present.
  433. */
  434. #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
  435. #define __DRI_USE_INVALIDATE_VERSION 1
  436. typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
  437. struct __DRIuseInvalidateExtensionRec {
  438. __DRIextension base;
  439. };
  440. /**
  441. * The remaining extensions describe driver extensions, immediately
  442. * available interfaces provided by the driver. To start using the
  443. * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
  444. * the extension you need in the array.
  445. */
  446. #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
  447. /**
  448. * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
  449. * suffixed by "_drivername", allowing multiple drivers to be built into one
  450. * library, and also giving the driver the chance to return a variable driver
  451. * extensions struct depending on the driver name being loaded or any other
  452. * system state.
  453. *
  454. * The function prototype is:
  455. *
  456. * const __DRIextension **__driDriverGetExtensions_drivername(void);
  457. */
  458. #define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
  459. /**
  460. * Tokens for __DRIconfig attribs. A number of attributes defined by
  461. * GLX or EGL standards are not in the table, as they must be provided
  462. * by the loader. For example, FBConfig ID or visual ID, drawable type.
  463. */
  464. #define __DRI_ATTRIB_BUFFER_SIZE 1
  465. #define __DRI_ATTRIB_LEVEL 2
  466. #define __DRI_ATTRIB_RED_SIZE 3
  467. #define __DRI_ATTRIB_GREEN_SIZE 4
  468. #define __DRI_ATTRIB_BLUE_SIZE 5
  469. #define __DRI_ATTRIB_LUMINANCE_SIZE 6
  470. #define __DRI_ATTRIB_ALPHA_SIZE 7
  471. #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
  472. #define __DRI_ATTRIB_DEPTH_SIZE 9
  473. #define __DRI_ATTRIB_STENCIL_SIZE 10
  474. #define __DRI_ATTRIB_ACCUM_RED_SIZE 11
  475. #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
  476. #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
  477. #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
  478. #define __DRI_ATTRIB_SAMPLE_BUFFERS 15
  479. #define __DRI_ATTRIB_SAMPLES 16
  480. #define __DRI_ATTRIB_RENDER_TYPE 17
  481. #define __DRI_ATTRIB_CONFIG_CAVEAT 18
  482. #define __DRI_ATTRIB_CONFORMANT 19
  483. #define __DRI_ATTRIB_DOUBLE_BUFFER 20
  484. #define __DRI_ATTRIB_STEREO 21
  485. #define __DRI_ATTRIB_AUX_BUFFERS 22
  486. #define __DRI_ATTRIB_TRANSPARENT_TYPE 23
  487. #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
  488. #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
  489. #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
  490. #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
  491. #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
  492. #define __DRI_ATTRIB_FLOAT_MODE 29
  493. #define __DRI_ATTRIB_RED_MASK 30
  494. #define __DRI_ATTRIB_GREEN_MASK 31
  495. #define __DRI_ATTRIB_BLUE_MASK 32
  496. #define __DRI_ATTRIB_ALPHA_MASK 33
  497. #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
  498. #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
  499. #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
  500. #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
  501. #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
  502. #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
  503. #define __DRI_ATTRIB_SWAP_METHOD 40
  504. #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
  505. #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
  506. #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
  507. #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
  508. #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
  509. #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
  510. #define __DRI_ATTRIB_YINVERTED 47
  511. #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
  512. /* __DRI_ATTRIB_RENDER_TYPE */
  513. #define __DRI_ATTRIB_RGBA_BIT 0x01
  514. #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
  515. #define __DRI_ATTRIB_LUMINANCE_BIT 0x04
  516. #define __DRI_ATTRIB_FLOAT_BIT 0x08
  517. #define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10
  518. /* __DRI_ATTRIB_CONFIG_CAVEAT */
  519. #define __DRI_ATTRIB_SLOW_BIT 0x01
  520. #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
  521. /* __DRI_ATTRIB_TRANSPARENT_TYPE */
  522. #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
  523. #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
  524. /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
  525. #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
  526. #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
  527. #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
  528. /**
  529. * This extension defines the core DRI functionality.
  530. */
  531. #define __DRI_CORE "DRI_Core"
  532. #define __DRI_CORE_VERSION 1
  533. struct __DRIcoreExtensionRec {
  534. __DRIextension base;
  535. __DRIscreen *(*createNewScreen)(int screen, int fd,
  536. unsigned int sarea_handle,
  537. const __DRIextension **extensions,
  538. const __DRIconfig ***driverConfigs,
  539. void *loaderPrivate);
  540. void (*destroyScreen)(__DRIscreen *screen);
  541. const __DRIextension **(*getExtensions)(__DRIscreen *screen);
  542. int (*getConfigAttrib)(const __DRIconfig *config,
  543. unsigned int attrib,
  544. unsigned int *value);
  545. int (*indexConfigAttrib)(const __DRIconfig *config, int index,
  546. unsigned int *attrib, unsigned int *value);
  547. __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
  548. const __DRIconfig *config,
  549. unsigned int drawable_id,
  550. unsigned int head,
  551. void *loaderPrivate);
  552. void (*destroyDrawable)(__DRIdrawable *drawable);
  553. void (*swapBuffers)(__DRIdrawable *drawable);
  554. __DRIcontext *(*createNewContext)(__DRIscreen *screen,
  555. const __DRIconfig *config,
  556. __DRIcontext *shared,
  557. void *loaderPrivate);
  558. int (*copyContext)(__DRIcontext *dest,
  559. __DRIcontext *src,
  560. unsigned long mask);
  561. void (*destroyContext)(__DRIcontext *context);
  562. int (*bindContext)(__DRIcontext *ctx,
  563. __DRIdrawable *pdraw,
  564. __DRIdrawable *pread);
  565. int (*unbindContext)(__DRIcontext *ctx);
  566. };
  567. /**
  568. * Stored version of some component (i.e., server-side DRI module, kernel-side
  569. * DRM, etc.).
  570. *
  571. * \todo
  572. * There are several data structures that explicitly store a major version,
  573. * minor version, and patch level. These structures should be modified to
  574. * have a \c __DRIversionRec instead.
  575. */
  576. struct __DRIversionRec {
  577. int major; /**< Major version number. */
  578. int minor; /**< Minor version number. */
  579. int patch; /**< Patch-level. */
  580. };
  581. /**
  582. * Framebuffer information record. Used by libGL to communicate information
  583. * about the framebuffer to the driver's \c __driCreateNewScreen function.
  584. *
  585. * In XFree86, most of this information is derrived from data returned by
  586. * calling \c XF86DRIGetDeviceInfo.
  587. *
  588. * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
  589. * __driUtilCreateNewScreen CallCreateNewScreen
  590. *
  591. * \bug This structure could be better named.
  592. */
  593. struct __DRIframebufferRec {
  594. unsigned char *base; /**< Framebuffer base address in the CPU's
  595. * address space. This value is calculated by
  596. * calling \c drmMap on the framebuffer handle
  597. * returned by \c XF86DRIGetDeviceInfo (or a
  598. * similar function).
  599. */
  600. int size; /**< Framebuffer size, in bytes. */
  601. int stride; /**< Number of bytes from one line to the next. */
  602. int width; /**< Pixel width of the framebuffer. */
  603. int height; /**< Pixel height of the framebuffer. */
  604. int dev_priv_size; /**< Size of the driver's dev-priv structure. */
  605. void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
  606. };
  607. /**
  608. * This extension provides alternative screen, drawable and context
  609. * constructors for legacy DRI functionality. This is used in
  610. * conjunction with the core extension.
  611. */
  612. #define __DRI_LEGACY "DRI_Legacy"
  613. #define __DRI_LEGACY_VERSION 1
  614. struct __DRIlegacyExtensionRec {
  615. __DRIextension base;
  616. __DRIscreen *(*createNewScreen)(int screen,
  617. const __DRIversion *ddx_version,
  618. const __DRIversion *dri_version,
  619. const __DRIversion *drm_version,
  620. const __DRIframebuffer *frame_buffer,
  621. void *pSAREA, int fd,
  622. const __DRIextension **extensions,
  623. const __DRIconfig ***driver_configs,
  624. void *loaderPrivate);
  625. __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
  626. const __DRIconfig *config,
  627. drm_drawable_t hwDrawable,
  628. int renderType, const int *attrs,
  629. void *loaderPrivate);
  630. __DRIcontext *(*createNewContext)(__DRIscreen *screen,
  631. const __DRIconfig *config,
  632. int render_type,
  633. __DRIcontext *shared,
  634. drm_context_t hwContext,
  635. void *loaderPrivate);
  636. };
  637. /**
  638. * This extension provides alternative screen, drawable and context
  639. * constructors for swrast DRI functionality. This is used in
  640. * conjunction with the core extension.
  641. */
  642. #define __DRI_SWRAST "DRI_SWRast"
  643. #define __DRI_SWRAST_VERSION 4
  644. struct __DRIswrastExtensionRec {
  645. __DRIextension base;
  646. __DRIscreen *(*createNewScreen)(int screen,
  647. const __DRIextension **extensions,
  648. const __DRIconfig ***driver_configs,
  649. void *loaderPrivate);
  650. __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
  651. const __DRIconfig *config,
  652. void *loaderPrivate);
  653. /* Since version 2 */
  654. __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
  655. int api,
  656. const __DRIconfig *config,
  657. __DRIcontext *shared,
  658. void *data);
  659. /**
  660. * Create a context for a particular API with a set of attributes
  661. *
  662. * \since version 3
  663. *
  664. * \sa __DRIdri2ExtensionRec::createContextAttribs
  665. */
  666. __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
  667. int api,
  668. const __DRIconfig *config,
  669. __DRIcontext *shared,
  670. unsigned num_attribs,
  671. const uint32_t *attribs,
  672. unsigned *error,
  673. void *loaderPrivate);
  674. /**
  675. * createNewScreen() with the driver extensions passed in.
  676. *
  677. * \since version 4
  678. */
  679. __DRIscreen *(*createNewScreen2)(int screen,
  680. const __DRIextension **loader_extensions,
  681. const __DRIextension **driver_extensions,
  682. const __DRIconfig ***driver_configs,
  683. void *loaderPrivate);
  684. };
  685. /** Common DRI function definitions, shared among DRI2 and Image extensions
  686. */
  687. typedef __DRIscreen *
  688. (*__DRIcreateNewScreen2Func)(int screen, int fd,
  689. const __DRIextension **extensions,
  690. const __DRIextension **driver_extensions,
  691. const __DRIconfig ***driver_configs,
  692. void *loaderPrivate);
  693. typedef __DRIdrawable *
  694. (*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
  695. const __DRIconfig *config,
  696. void *loaderPrivate);
  697. typedef __DRIcontext *
  698. (*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
  699. int api,
  700. const __DRIconfig *config,
  701. __DRIcontext *shared,
  702. unsigned num_attribs,
  703. const uint32_t *attribs,
  704. unsigned *error,
  705. void *loaderPrivate);
  706. typedef unsigned int
  707. (*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
  708. /**
  709. * DRI2 Loader extension.
  710. */
  711. #define __DRI_BUFFER_FRONT_LEFT 0
  712. #define __DRI_BUFFER_BACK_LEFT 1
  713. #define __DRI_BUFFER_FRONT_RIGHT 2
  714. #define __DRI_BUFFER_BACK_RIGHT 3
  715. #define __DRI_BUFFER_DEPTH 4
  716. #define __DRI_BUFFER_STENCIL 5
  717. #define __DRI_BUFFER_ACCUM 6
  718. #define __DRI_BUFFER_FAKE_FRONT_LEFT 7
  719. #define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
  720. #define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
  721. #define __DRI_BUFFER_HIZ 10
  722. /* Inofficial and for internal use. Increase when adding a new buffer token. */
  723. #define __DRI_BUFFER_COUNT 11
  724. struct __DRIbufferRec {
  725. unsigned int attachment;
  726. unsigned int name;
  727. unsigned int pitch;
  728. unsigned int cpp;
  729. unsigned int flags;
  730. };
  731. #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
  732. #define __DRI_DRI2_LOADER_VERSION 3
  733. struct __DRIdri2LoaderExtensionRec {
  734. __DRIextension base;
  735. __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
  736. int *width, int *height,
  737. unsigned int *attachments, int count,
  738. int *out_count, void *loaderPrivate);
  739. /**
  740. * Flush pending front-buffer rendering
  741. *
  742. * Any rendering that has been performed to the
  743. * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
  744. * \c __DRI_BUFFER_FRONT_LEFT.
  745. *
  746. * \param driDrawable Drawable whose front-buffer is to be flushed
  747. * \param loaderPrivate Loader's private data that was previously passed
  748. * into __DRIdri2ExtensionRec::createNewDrawable
  749. *
  750. * \since 2
  751. */
  752. void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
  753. /**
  754. * Get list of buffers from the server
  755. *
  756. * Gets a list of buffer for the specified set of attachments. Unlike
  757. * \c ::getBuffers, this function takes a list of attachments paired with
  758. * opaque \c unsigned \c int value describing the format of the buffer.
  759. * It is the responsibility of the caller to know what the service that
  760. * allocates the buffers will expect to receive for the format.
  761. *
  762. * \param driDrawable Drawable whose buffers are being queried.
  763. * \param width Output where the width of the buffers is stored.
  764. * \param height Output where the height of the buffers is stored.
  765. * \param attachments List of pairs of attachment ID and opaque format
  766. * requested for the drawable.
  767. * \param count Number of attachment / format pairs stored in
  768. * \c attachments.
  769. * \param loaderPrivate Loader's private data that was previously passed
  770. * into __DRIdri2ExtensionRec::createNewDrawable.
  771. *
  772. * \since 3
  773. */
  774. __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
  775. int *width, int *height,
  776. unsigned int *attachments, int count,
  777. int *out_count, void *loaderPrivate);
  778. };
  779. /**
  780. * This extension provides alternative screen, drawable and context
  781. * constructors for DRI2.
  782. */
  783. #define __DRI_DRI2 "DRI_DRI2"
  784. #define __DRI_DRI2_VERSION 4
  785. #define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
  786. #define __DRI_API_GLES 1 /**< OpenGL ES 1.x */
  787. #define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */
  788. #define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
  789. #define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */
  790. #define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
  791. #define __DRI_CTX_ATTRIB_MINOR_VERSION 1
  792. #define __DRI_CTX_ATTRIB_FLAGS 2
  793. /**
  794. * \requires __DRI2_ROBUSTNESS.
  795. */
  796. #define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
  797. #define __DRI_CTX_FLAG_DEBUG 0x00000001
  798. #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
  799. /**
  800. * \requires __DRI2_ROBUSTNESS.
  801. */
  802. #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004
  803. /**
  804. * \name Context reset strategies.
  805. */
  806. /*@{*/
  807. #define __DRI_CTX_RESET_NO_NOTIFICATION 0
  808. #define __DRI_CTX_RESET_LOSE_CONTEXT 1
  809. /*@}*/
  810. /**
  811. * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
  812. */
  813. /*@{*/
  814. /** Success! */
  815. #define __DRI_CTX_ERROR_SUCCESS 0
  816. /** Memory allocation failure */
  817. #define __DRI_CTX_ERROR_NO_MEMORY 1
  818. /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
  819. #define __DRI_CTX_ERROR_BAD_API 2
  820. /** Client requested an API version that the driver can't do. */
  821. #define __DRI_CTX_ERROR_BAD_VERSION 3
  822. /** Client requested a flag or combination of flags the driver can't do. */
  823. #define __DRI_CTX_ERROR_BAD_FLAG 4
  824. /** Client requested an attribute the driver doesn't understand. */
  825. #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
  826. /** Client requested a flag the driver doesn't understand. */
  827. #define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
  828. /*@}*/
  829. struct __DRIdri2ExtensionRec {
  830. __DRIextension base;
  831. __DRIscreen *(*createNewScreen)(int screen, int fd,
  832. const __DRIextension **extensions,
  833. const __DRIconfig ***driver_configs,
  834. void *loaderPrivate);
  835. __DRIcreateNewDrawableFunc createNewDrawable;
  836. __DRIcontext *(*createNewContext)(__DRIscreen *screen,
  837. const __DRIconfig *config,
  838. __DRIcontext *shared,
  839. void *loaderPrivate);
  840. /* Since version 2 */
  841. __DRIgetAPIMaskFunc getAPIMask;
  842. __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
  843. int api,
  844. const __DRIconfig *config,
  845. __DRIcontext *shared,
  846. void *data);
  847. __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
  848. unsigned int attachment,
  849. unsigned int format,
  850. int width,
  851. int height);
  852. void (*releaseBuffer)(__DRIscreen *screen,
  853. __DRIbuffer *buffer);
  854. /**
  855. * Create a context for a particular API with a set of attributes
  856. *
  857. * \since version 3
  858. *
  859. * \sa __DRIswrastExtensionRec::createContextAttribs
  860. */
  861. __DRIcreateContextAttribsFunc createContextAttribs;
  862. /**
  863. * createNewScreen with the driver's extension list passed in.
  864. *
  865. * \since version 4
  866. */
  867. __DRIcreateNewScreen2Func createNewScreen2;
  868. };
  869. /**
  870. * This extension provides functionality to enable various EGLImage
  871. * extensions.
  872. */
  873. #define __DRI_IMAGE "DRI_IMAGE"
  874. #define __DRI_IMAGE_VERSION 10
  875. /**
  876. * These formats correspond to the similarly named MESA_FORMAT_*
  877. * tokens, except in the native endian of the CPU. For example, on
  878. * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
  879. * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
  880. *
  881. * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
  882. * by the driver (YUV planar formats) but serve as a base image for
  883. * creating sub-images for the different planes within the image.
  884. *
  885. * R8, GR88 and NONE should not be used with createImageFormName or
  886. * createImage, and are returned by query from sub images created with
  887. * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
  888. */
  889. #define __DRI_IMAGE_FORMAT_RGB565 0x1001
  890. #define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
  891. #define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
  892. #define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
  893. #define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
  894. #define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
  895. #define __DRI_IMAGE_FORMAT_GR88 0x1007
  896. #define __DRI_IMAGE_FORMAT_NONE 0x1008
  897. #define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
  898. #define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
  899. #define __DRI_IMAGE_FORMAT_SARGB8 0x100b
  900. #define __DRI_IMAGE_USE_SHARE 0x0001
  901. #define __DRI_IMAGE_USE_SCANOUT 0x0002
  902. #define __DRI_IMAGE_USE_CURSOR 0x0004 /* Depricated */
  903. #define __DRI_IMAGE_USE_LINEAR 0x0008
  904. /**
  905. * Four CC formats that matches with WL_DRM_FORMAT_* from wayland_drm.h
  906. * and GBM_FORMAT_* from gbm.h, used with createImageFromNames.
  907. *
  908. * \since 5
  909. */
  910. #define __DRI_IMAGE_FOURCC_RGB565 0x36314752
  911. #define __DRI_IMAGE_FOURCC_ARGB8888 0x34325241
  912. #define __DRI_IMAGE_FOURCC_XRGB8888 0x34325258
  913. #define __DRI_IMAGE_FOURCC_ABGR8888 0x34324241
  914. #define __DRI_IMAGE_FOURCC_XBGR8888 0x34324258
  915. #define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258
  916. #define __DRI_IMAGE_FOURCC_YUV410 0x39565559
  917. #define __DRI_IMAGE_FOURCC_YUV411 0x31315559
  918. #define __DRI_IMAGE_FOURCC_YUV420 0x32315559
  919. #define __DRI_IMAGE_FOURCC_YUV422 0x36315559
  920. #define __DRI_IMAGE_FOURCC_YUV444 0x34325559
  921. #define __DRI_IMAGE_FOURCC_NV12 0x3231564e
  922. #define __DRI_IMAGE_FOURCC_NV16 0x3631564e
  923. #define __DRI_IMAGE_FOURCC_YUYV 0x56595559
  924. /**
  925. * Queryable on images created by createImageFromNames.
  926. *
  927. * RGB and RGBA are may be usable directly as images but its still
  928. * recommended to call fromPlanar with plane == 0.
  929. *
  930. * Y_U_V, Y_UV and Y_XUXV all requires call to fromPlanar to create
  931. * usable sub-images, sampling from images return raw YUV data and
  932. * color conversion needs to be done in the shader.
  933. *
  934. * \since 5
  935. */
  936. #define __DRI_IMAGE_COMPONENTS_RGB 0x3001
  937. #define __DRI_IMAGE_COMPONENTS_RGBA 0x3002
  938. #define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
  939. #define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
  940. #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
  941. /**
  942. * queryImage attributes
  943. */
  944. #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
  945. #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
  946. #define __DRI_IMAGE_ATTRIB_NAME 0x2002
  947. #define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
  948. #define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */
  949. #define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005
  950. #define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */
  951. #define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions
  952. * 7+. Each query will return a
  953. * new fd. */
  954. enum __DRIYUVColorSpace {
  955. __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
  956. __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
  957. __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
  958. __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
  959. };
  960. enum __DRISampleRange {
  961. __DRI_YUV_RANGE_UNDEFINED = 0,
  962. __DRI_YUV_FULL_RANGE = 0x3282,
  963. __DRI_YUV_NARROW_RANGE = 0x3283
  964. };
  965. enum __DRIChromaSiting {
  966. __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
  967. __DRI_YUV_CHROMA_SITING_0 = 0x3284,
  968. __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
  969. };
  970. /**
  971. * \name Reasons that __DRIimageExtensionRec::createImageFromTexture might fail
  972. */
  973. /*@{*/
  974. /** Success! */
  975. #define __DRI_IMAGE_ERROR_SUCCESS 0
  976. /** Memory allocation failure */
  977. #define __DRI_IMAGE_ERROR_BAD_ALLOC 1
  978. /** Client requested an invalid attribute for a texture object */
  979. #define __DRI_IMAGE_ERROR_BAD_MATCH 2
  980. /** Client requested an invalid texture object */
  981. #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
  982. /*@}*/
  983. /**
  984. * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
  985. */
  986. /*@{*/
  987. #define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
  988. /*@}*/
  989. /**
  990. * blitImage flags
  991. */
  992. #define __BLIT_FLAG_FLUSH 0x0001
  993. #define __BLIT_FLAG_FINISH 0x0002
  994. typedef struct __DRIimageRec __DRIimage;
  995. typedef struct __DRIimageExtensionRec __DRIimageExtension;
  996. struct __DRIimageExtensionRec {
  997. __DRIextension base;
  998. __DRIimage *(*createImageFromName)(__DRIscreen *screen,
  999. int width, int height, int format,
  1000. int name, int pitch,
  1001. void *loaderPrivate);
  1002. __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
  1003. int renderbuffer,
  1004. void *loaderPrivate);
  1005. void (*destroyImage)(__DRIimage *image);
  1006. __DRIimage *(*createImage)(__DRIscreen *screen,
  1007. int width, int height, int format,
  1008. unsigned int use,
  1009. void *loaderPrivate);
  1010. GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
  1011. /**
  1012. * The new __DRIimage will share the content with the old one, see dup(2).
  1013. */
  1014. __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
  1015. /**
  1016. * Validate that a __DRIimage can be used a certain way.
  1017. *
  1018. * \since 2
  1019. */
  1020. GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
  1021. /**
  1022. * Unlike createImageFromName __DRI_IMAGE_FORMAT is not but instead
  1023. * __DRI_IMAGE_FOURCC and strides are in bytes not pixels. Stride is
  1024. * also per block and not per pixel (for non-RGB, see gallium blocks).
  1025. *
  1026. * \since 5
  1027. */
  1028. __DRIimage *(*createImageFromNames)(__DRIscreen *screen,
  1029. int width, int height, int fourcc,
  1030. int *names, int num_names,
  1031. int *strides, int *offsets,
  1032. void *loaderPrivate);
  1033. /**
  1034. * Create an image out of a sub-region of a parent image. This
  1035. * entry point lets us create individual __DRIimages for different
  1036. * planes in a planar buffer (typically yuv), for example. While a
  1037. * sub-image shares the underlying buffer object with the parent
  1038. * image and other sibling sub-images, the life times of parent and
  1039. * sub-images are not dependent. Destroying the parent or a
  1040. * sub-image doesn't affect other images. The underlying buffer
  1041. * object is free when no __DRIimage remains that references it.
  1042. *
  1043. * Sub-images may overlap, but rendering to overlapping sub-images
  1044. * is undefined.
  1045. *
  1046. * \since 5
  1047. */
  1048. __DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
  1049. void *loaderPrivate);
  1050. /**
  1051. * Create image from texture.
  1052. *
  1053. * \since 6
  1054. */
  1055. __DRIimage *(*createImageFromTexture)(__DRIcontext *context,
  1056. int target,
  1057. unsigned texture,
  1058. int depth,
  1059. int level,
  1060. unsigned *error,
  1061. void *loaderPrivate);
  1062. /**
  1063. * Like createImageFromNames, but takes a prime fd instead.
  1064. *
  1065. * \since 7
  1066. */
  1067. __DRIimage *(*createImageFromFds)(__DRIscreen *screen,
  1068. int width, int height, int fourcc,
  1069. int *fds, int num_fds,
  1070. int *strides, int *offsets,
  1071. void *loaderPrivate);
  1072. /**
  1073. * Like createImageFromFds, but takes additional attributes.
  1074. *
  1075. * For EGL_EXT_image_dma_buf_import.
  1076. *
  1077. * \since 8
  1078. */
  1079. __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
  1080. int width, int height, int fourcc,
  1081. int *fds, int num_fds,
  1082. int *strides, int *offsets,
  1083. enum __DRIYUVColorSpace color_space,
  1084. enum __DRISampleRange sample_range,
  1085. enum __DRIChromaSiting horiz_siting,
  1086. enum __DRIChromaSiting vert_siting,
  1087. unsigned *error,
  1088. void *loaderPrivate);
  1089. /**
  1090. * Blit a part of a __DRIimage to another and flushes
  1091. *
  1092. * flush_flag:
  1093. * 0: no flush
  1094. * __BLIT_FLAG_FLUSH: flush after the blit operation
  1095. * __BLIT_FLAG_FINISH: flush and wait the blit finished
  1096. *
  1097. * \since 9
  1098. */
  1099. void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
  1100. int dstx0, int dsty0, int dstwidth, int dstheight,
  1101. int srcx0, int srcy0, int srcwidth, int srcheight,
  1102. int flush_flag);
  1103. /**
  1104. * Query for general capabilities of the driver that concern
  1105. * buffer sharing and image importing.
  1106. *
  1107. * \since 10
  1108. */
  1109. int (*getCapabilities)(__DRIscreen *screen);
  1110. };
  1111. /**
  1112. * This extension must be implemented by the loader and passed to the
  1113. * driver at screen creation time. The EGLImage entry points in the
  1114. * various client APIs take opaque EGLImage handles and use this
  1115. * extension to map them to a __DRIimage. At version 1, this
  1116. * extensions allows mapping EGLImage pointers to __DRIimage pointers,
  1117. * but future versions could support other EGLImage-like, opaque types
  1118. * with new lookup functions.
  1119. */
  1120. #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
  1121. #define __DRI_IMAGE_LOOKUP_VERSION 1
  1122. typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
  1123. struct __DRIimageLookupExtensionRec {
  1124. __DRIextension base;
  1125. __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
  1126. void *loaderPrivate);
  1127. };
  1128. /**
  1129. * This extension allows for common DRI2 options
  1130. */
  1131. #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
  1132. #define __DRI2_CONFIG_QUERY_VERSION 1
  1133. typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
  1134. struct __DRI2configQueryExtensionRec {
  1135. __DRIextension base;
  1136. int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);
  1137. int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
  1138. int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
  1139. };
  1140. /**
  1141. * Robust context driver extension.
  1142. *
  1143. * Existence of this extension means the driver can accept the
  1144. * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
  1145. * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
  1146. * \c __DRIdri2ExtensionRec::createContextAttribs.
  1147. */
  1148. #define __DRI2_ROBUSTNESS "DRI_Robustness"
  1149. #define __DRI2_ROBUSTNESS_VERSION 1
  1150. typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
  1151. struct __DRIrobustnessExtensionRec {
  1152. __DRIextension base;
  1153. };
  1154. /**
  1155. * DRI config options extension.
  1156. *
  1157. * This extension provides the XML string containing driver options for use by
  1158. * the loader in supporting the driconf application.
  1159. */
  1160. #define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
  1161. #define __DRI_CONFIG_OPTIONS_VERSION 1
  1162. typedef struct __DRIconfigOptionsExtensionRec {
  1163. __DRIextension base;
  1164. const char *xml;
  1165. } __DRIconfigOptionsExtension;
  1166. /**
  1167. * This extension provides a driver vtable to a set of common driver helper
  1168. * functions (driCoreExtension, driDRI2Extension) within the driver
  1169. * implementation, as opposed to having to pass them through a global
  1170. * variable.
  1171. *
  1172. * It is not intended to be public API to the actual loader, and the vtable
  1173. * layout may change at any time.
  1174. */
  1175. #define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
  1176. #define __DRI_DRIVER_VTABLE_VERSION 1
  1177. typedef struct __DRIDriverVtableExtensionRec {
  1178. __DRIextension base;
  1179. const struct __DriverAPIRec *vtable;
  1180. } __DRIDriverVtableExtension;
  1181. /**
  1182. * Query renderer driver extension
  1183. *
  1184. * This allows the window system layer (either EGL or GLX) to query aspects of
  1185. * hardware and driver support without creating a context.
  1186. */
  1187. #define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
  1188. #define __DRI2_RENDERER_QUERY_VERSION 1
  1189. #define __DRI2_RENDERER_VENDOR_ID 0x0000
  1190. #define __DRI2_RENDERER_DEVICE_ID 0x0001
  1191. #define __DRI2_RENDERER_VERSION 0x0002
  1192. #define __DRI2_RENDERER_ACCELERATED 0x0003
  1193. #define __DRI2_RENDERER_VIDEO_MEMORY 0x0004
  1194. #define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005
  1195. #define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006
  1196. #define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007
  1197. #define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008
  1198. #define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009
  1199. #define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a
  1200. typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
  1201. struct __DRI2rendererQueryExtensionRec {
  1202. __DRIextension base;
  1203. int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
  1204. int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
  1205. };
  1206. /**
  1207. * Image Loader extension. Drivers use this to allocate color buffers
  1208. */
  1209. enum __DRIimageBufferMask {
  1210. __DRI_IMAGE_BUFFER_BACK = (1 << 0),
  1211. __DRI_IMAGE_BUFFER_FRONT = (1 << 1)
  1212. };
  1213. struct __DRIimageList {
  1214. uint32_t image_mask;
  1215. __DRIimage *back;
  1216. __DRIimage *front;
  1217. };
  1218. #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
  1219. #define __DRI_IMAGE_LOADER_VERSION 1
  1220. struct __DRIimageLoaderExtensionRec {
  1221. __DRIextension base;
  1222. /**
  1223. * Allocate color buffers.
  1224. *
  1225. * \param driDrawable
  1226. * \param width Width of allocated buffers
  1227. * \param height Height of allocated buffers
  1228. * \param format one of __DRI_IMAGE_FORMAT_*
  1229. * \param stamp Address of variable to be updated when
  1230. * getBuffers must be called again
  1231. * \param loaderPrivate The loaderPrivate for driDrawable
  1232. * \param buffer_mask Set of buffers to allocate
  1233. * \param buffers Returned buffers
  1234. */
  1235. int (*getBuffers)(__DRIdrawable *driDrawable,
  1236. unsigned int format,
  1237. uint32_t *stamp,
  1238. void *loaderPrivate,
  1239. uint32_t buffer_mask,
  1240. struct __DRIimageList *buffers);
  1241. /**
  1242. * Flush pending front-buffer rendering
  1243. *
  1244. * Any rendering that has been performed to the
  1245. * fake front will be flushed to the front
  1246. *
  1247. * \param driDrawable Drawable whose front-buffer is to be flushed
  1248. * \param loaderPrivate Loader's private data that was previously passed
  1249. * into __DRIdri2ExtensionRec::createNewDrawable
  1250. */
  1251. void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
  1252. };
  1253. /**
  1254. * DRI extension.
  1255. */
  1256. #define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"
  1257. #define __DRI_IMAGE_DRIVER_VERSION 1
  1258. struct __DRIimageDriverExtensionRec {
  1259. __DRIextension base;
  1260. /* Common DRI functions, shared with DRI2 */
  1261. __DRIcreateNewScreen2Func createNewScreen2;
  1262. __DRIcreateNewDrawableFunc createNewDrawable;
  1263. __DRIcreateContextAttribsFunc createContextAttribs;
  1264. __DRIgetAPIMaskFunc getAPIMask;
  1265. };
  1266. #endif