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 51KB

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