dri_interface.h 82 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804180518061807180818091810181118121813181418151816181718181819182018211822182318241825182618271828182918301831183218331834183518361837183818391840184118421843184418451846184718481849185018511852185318541855185618571858185918601861186218631864186518661867186818691870187118721873187418751876187718781879188018811882188318841885188618871888188918901891189218931894189518961897189818991900190119021903190419051906190719081909191019111912191319141915191619171918191919201921192219231924192519261927192819291930193119321933193419351936193719381939194019411942194319441945194619471948194919501951195219531954195519561957195819591960196119621963196419651966196719681969197019711972197319741975197619771978197919801981198219831984198519861987198819891990199119921993199419951996199719981999200020012002200320042005200620072008200920102011201220132014201520162017201820192020202120222023202420252026202720282029203020312032203320342035203620372038203920402041204220432044204520462047204820492050205120522053205420552056205720582059206020612062206320642065206620672068206920702071207220732074207520762077207820792080208120822083208420852086208720882089209020912092209320942095209620972098209921002101210221032104210521062107210821092110211121122113211421152116211721182119212021212122212321242125212621272128212921302131213221332134213521362137213821392140214121422143214421452146214721482149215021512152215321542155215621572158215921602161216221632164216521662167216821692170217121722173217421752176217721782179218021812182218321842185218621872188218921902191219221932194219521962197219821992200220122022203220422052206220722082209221022112212221322142215221622172218221922202221222222232224222522262227222822292230223122322233223422352236223722382239224022412242224322442245224622472248224922502251225222532254225522562257225822592260226122622263226422652266226722682269227022712272227322742275227622772278227922802281228222832284228522862287228822892290229122922293229422952296229722982299230023012302230323042305230623072308230923102311231223132314231523162317231823192320232123222323232423252326232723282329233023312332233323342335233623372338233923402341234223432344234523462347234823492350235123522353235423552356
  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. #include <GL/gl.h>
  48. #include <stdint.h>
  49. /**
  50. * \name DRI interface structures
  51. *
  52. * The following structures define the interface between the GLX client
  53. * side library and the DRI (direct rendering infrastructure).
  54. */
  55. /*@{*/
  56. typedef struct __DRIdisplayRec __DRIdisplay;
  57. typedef struct __DRIscreenRec __DRIscreen;
  58. typedef struct __DRIcontextRec __DRIcontext;
  59. typedef struct __DRIdrawableRec __DRIdrawable;
  60. typedef struct __DRIconfigRec __DRIconfig;
  61. typedef struct __DRIframebufferRec __DRIframebuffer;
  62. typedef struct __DRIversionRec __DRIversion;
  63. typedef struct __DRIcoreExtensionRec __DRIcoreExtension;
  64. typedef struct __DRIextensionRec __DRIextension;
  65. typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
  66. typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
  67. typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
  68. typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
  69. typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
  70. typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;
  71. typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;
  72. typedef struct __DRIswrastExtensionRec __DRIswrastExtension;
  73. typedef struct __DRIbufferRec __DRIbuffer;
  74. typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;
  75. typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;
  76. typedef struct __DRI2flushExtensionRec __DRI2flushExtension;
  77. typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension;
  78. typedef struct __DRI2fenceExtensionRec __DRI2fenceExtension;
  79. typedef struct __DRI2interopExtensionRec __DRI2interopExtension;
  80. typedef struct __DRI2blobExtensionRec __DRI2blobExtension;
  81. typedef struct __DRI2bufferDamageExtensionRec __DRI2bufferDamageExtension;
  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. * Extension for EGL_ANDROID_blob_cache
  303. */
  304. #define __DRI2_BLOB "DRI2_Blob"
  305. #define __DRI2_BLOB_VERSION 1
  306. typedef void
  307. (*__DRIblobCacheSet) (const void *key, signed long keySize,
  308. const void *value, signed long valueSize);
  309. typedef signed long
  310. (*__DRIblobCacheGet) (const void *key, signed long keySize,
  311. void *value, signed long valueSize);
  312. struct __DRI2blobExtensionRec {
  313. __DRIextension base;
  314. /**
  315. * Set cache functions for setting and getting cache entries.
  316. */
  317. void (*set_cache_funcs) (__DRIscreen *screen,
  318. __DRIblobCacheSet set, __DRIblobCacheGet get);
  319. };
  320. /**
  321. * Extension for fences / synchronization objects.
  322. */
  323. #define __DRI2_FENCE "DRI2_Fence"
  324. #define __DRI2_FENCE_VERSION 2
  325. #define __DRI2_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffull
  326. #define __DRI2_FENCE_FLAG_FLUSH_COMMANDS (1 << 0)
  327. /**
  328. * \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities
  329. */
  330. /*@{*/
  331. #define __DRI_FENCE_CAP_NATIVE_FD 1
  332. /*@}*/
  333. struct __DRI2fenceExtensionRec {
  334. __DRIextension base;
  335. /**
  336. * Create and insert a fence into the command stream of the context.
  337. */
  338. void *(*create_fence)(__DRIcontext *ctx);
  339. /**
  340. * Get a fence associated with the OpenCL event object.
  341. * This can be NULL, meaning that OpenCL interoperability is not supported.
  342. */
  343. void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event);
  344. /**
  345. * Destroy a fence.
  346. */
  347. void (*destroy_fence)(__DRIscreen *screen, void *fence);
  348. /**
  349. * This function waits and doesn't return until the fence is signalled
  350. * or the timeout expires. It returns true if the fence has been signaled.
  351. *
  352. * \param ctx the context where commands are flushed
  353. * \param fence the fence
  354. * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags
  355. * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE
  356. */
  357. GLboolean (*client_wait_sync)(__DRIcontext *ctx, void *fence,
  358. unsigned flags, uint64_t timeout);
  359. /**
  360. * This function enqueues a wait command into the command stream of
  361. * the context and then returns. When the execution reaches the wait
  362. * command, no further execution will be done in the context until
  363. * the fence is signaled. This is a no-op if the device doesn't support
  364. * parallel execution of contexts.
  365. *
  366. * \param ctx the context where the waiting is done
  367. * \param fence the fence
  368. * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags that make
  369. * sense with this function (right now there are none)
  370. */
  371. void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags);
  372. /**
  373. * Query for general capabilities of the driver that concern fences.
  374. * Returns a bitmask of __DRI_FENCE_CAP_x
  375. *
  376. * \since 2
  377. */
  378. unsigned (*get_capabilities)(__DRIscreen *screen);
  379. /**
  380. * Create an fd (file descriptor) associated fence. If the fence fd
  381. * is -1, this behaves similarly to create_fence() except that when
  382. * rendering is flushed the driver creates a fence fd. Otherwise,
  383. * the driver wraps an existing fence fd.
  384. *
  385. * This is used to implement the EGL_ANDROID_native_fence_sync extension.
  386. *
  387. * \since 2
  388. *
  389. * \param ctx the context associated with the fence
  390. * \param fd the fence fd or -1
  391. */
  392. void *(*create_fence_fd)(__DRIcontext *ctx, int fd);
  393. /**
  394. * For fences created with create_fence_fd(), after rendering is flushed,
  395. * this retrieves the native fence fd. Caller takes ownership of the
  396. * fd and will close() it when it is no longer needed.
  397. *
  398. * \since 2
  399. *
  400. * \param screen the screen associated with the fence
  401. * \param fence the fence
  402. */
  403. int (*get_fence_fd)(__DRIscreen *screen, void *fence);
  404. };
  405. /**
  406. * Extension for API interop.
  407. * See GL/mesa_glinterop.h.
  408. */
  409. #define __DRI2_INTEROP "DRI2_Interop"
  410. #define __DRI2_INTEROP_VERSION 1
  411. struct mesa_glinterop_device_info;
  412. struct mesa_glinterop_export_in;
  413. struct mesa_glinterop_export_out;
  414. struct __DRI2interopExtensionRec {
  415. __DRIextension base;
  416. /** Same as MesaGLInterop*QueryDeviceInfo. */
  417. int (*query_device_info)(__DRIcontext *ctx,
  418. struct mesa_glinterop_device_info *out);
  419. /** Same as MesaGLInterop*ExportObject. */
  420. int (*export_object)(__DRIcontext *ctx,
  421. struct mesa_glinterop_export_in *in,
  422. struct mesa_glinterop_export_out *out);
  423. };
  424. /**
  425. * Extension for limiting window system back buffer rendering to user-defined
  426. * scissor region.
  427. */
  428. #define __DRI2_BUFFER_DAMAGE "DRI2_BufferDamage"
  429. #define __DRI2_BUFFER_DAMAGE_VERSION 1
  430. struct __DRI2bufferDamageExtensionRec {
  431. __DRIextension base;
  432. /**
  433. * Provides an array of rectangles representing an overriding scissor region
  434. * for rendering operations performed to the specified drawable. These
  435. * rectangles do not replace client API scissor regions or draw
  436. * co-ordinates, but instead inform the driver of the overall bounds of all
  437. * operations which will be issued before the next flush.
  438. *
  439. * Any rendering operations writing pixels outside this region to the
  440. * drawable will have an undefined effect on the entire drawable.
  441. *
  442. * This entrypoint may only be called after the drawable has either been
  443. * newly created or flushed, and before any rendering operations which write
  444. * pixels to the drawable. Calling this entrypoint at any other time will
  445. * have an undefined effect on the entire drawable.
  446. *
  447. * Calling this entrypoint with @nrects 0 and @rects NULL will reset the
  448. * region to the buffer's full size. This entrypoint may be called once to
  449. * reset the region, followed by a second call with a populated region,
  450. * before a rendering call is made.
  451. *
  452. * Used to implement EGL_KHR_partial_update.
  453. *
  454. * \param drawable affected drawable
  455. * \param nrects number of rectangles provided
  456. * \param rects the array of rectangles, lower-left origin
  457. */
  458. void (*set_damage_region)(__DRIdrawable *drawable, unsigned int nrects,
  459. int *rects);
  460. };
  461. /*@}*/
  462. /**
  463. * The following extensions describe loader features that the DRI
  464. * driver can make use of. Some of these are mandatory, such as the
  465. * getDrawableInfo extension for DRI and the DRI Loader extensions for
  466. * DRI2, while others are optional, and if present allow the driver to
  467. * expose certain features. The loader pass in a NULL terminated
  468. * array of these extensions to the driver in the createNewScreen
  469. * constructor.
  470. */
  471. typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
  472. typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
  473. typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
  474. typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
  475. typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
  476. /**
  477. * Callback to getDrawableInfo protocol
  478. */
  479. #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
  480. #define __DRI_GET_DRAWABLE_INFO_VERSION 1
  481. struct __DRIgetDrawableInfoExtensionRec {
  482. __DRIextension base;
  483. /**
  484. * This function is used to get information about the position, size, and
  485. * clip rects of a drawable.
  486. */
  487. GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
  488. unsigned int * index, unsigned int * stamp,
  489. int * x, int * y, int * width, int * height,
  490. int * numClipRects, drm_clip_rect_t ** pClipRects,
  491. int * backX, int * backY,
  492. int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
  493. void *loaderPrivate);
  494. };
  495. /**
  496. * Callback to get system time for media stream counter extensions.
  497. */
  498. #define __DRI_SYSTEM_TIME "DRI_SystemTime"
  499. #define __DRI_SYSTEM_TIME_VERSION 1
  500. struct __DRIsystemTimeExtensionRec {
  501. __DRIextension base;
  502. /**
  503. * Get the 64-bit unadjusted system time (UST).
  504. */
  505. int (*getUST)(int64_t * ust);
  506. /**
  507. * Get the media stream counter (MSC) rate.
  508. *
  509. * Matching the definition in GLX_OML_sync_control, this function returns
  510. * the rate of the "media stream counter". In practical terms, this is
  511. * the frame refresh rate of the display.
  512. */
  513. GLboolean (*getMSCRate)(__DRIdrawable *draw,
  514. int32_t * numerator, int32_t * denominator,
  515. void *loaderPrivate);
  516. };
  517. /**
  518. * Damage reporting
  519. */
  520. #define __DRI_DAMAGE "DRI_Damage"
  521. #define __DRI_DAMAGE_VERSION 1
  522. struct __DRIdamageExtensionRec {
  523. __DRIextension base;
  524. /**
  525. * Reports areas of the given drawable which have been modified by the
  526. * driver.
  527. *
  528. * \param drawable which the drawing was done to.
  529. * \param rects rectangles affected, with the drawable origin as the
  530. * origin.
  531. * \param x X offset of the drawable within the screen (used in the
  532. * front_buffer case)
  533. * \param y Y offset of the drawable within the screen.
  534. * \param front_buffer boolean flag for whether the drawing to the
  535. * drawable was actually done directly to the front buffer (instead
  536. * of backing storage, for example)
  537. * \param loaderPrivate the data passed in at createNewDrawable time
  538. */
  539. void (*reportDamage)(__DRIdrawable *draw,
  540. int x, int y,
  541. drm_clip_rect_t *rects, int num_rects,
  542. GLboolean front_buffer,
  543. void *loaderPrivate);
  544. };
  545. #define __DRI_SWRAST_IMAGE_OP_DRAW 1
  546. #define __DRI_SWRAST_IMAGE_OP_CLEAR 2
  547. #define __DRI_SWRAST_IMAGE_OP_SWAP 3
  548. /**
  549. * SWRast Loader extension.
  550. */
  551. #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
  552. #define __DRI_SWRAST_LOADER_VERSION 6
  553. struct __DRIswrastLoaderExtensionRec {
  554. __DRIextension base;
  555. /*
  556. * Drawable position and size
  557. */
  558. void (*getDrawableInfo)(__DRIdrawable *drawable,
  559. int *x, int *y, int *width, int *height,
  560. void *loaderPrivate);
  561. /**
  562. * Put image to drawable
  563. */
  564. void (*putImage)(__DRIdrawable *drawable, int op,
  565. int x, int y, int width, int height,
  566. char *data, void *loaderPrivate);
  567. /**
  568. * Get image from readable
  569. */
  570. void (*getImage)(__DRIdrawable *readable,
  571. int x, int y, int width, int height,
  572. char *data, void *loaderPrivate);
  573. /**
  574. * Put image to drawable
  575. *
  576. * \since 2
  577. */
  578. void (*putImage2)(__DRIdrawable *drawable, int op,
  579. int x, int y, int width, int height, int stride,
  580. char *data, void *loaderPrivate);
  581. /**
  582. * Put image to drawable
  583. *
  584. * \since 3
  585. */
  586. void (*getImage2)(__DRIdrawable *readable,
  587. int x, int y, int width, int height, int stride,
  588. char *data, void *loaderPrivate);
  589. /**
  590. * Put shm image to drawable
  591. *
  592. * \since 4
  593. */
  594. void (*putImageShm)(__DRIdrawable *drawable, int op,
  595. int x, int y, int width, int height, int stride,
  596. int shmid, char *shmaddr, unsigned offset,
  597. void *loaderPrivate);
  598. /**
  599. * Get shm image from readable
  600. *
  601. * \since 4
  602. */
  603. void (*getImageShm)(__DRIdrawable *readable,
  604. int x, int y, int width, int height,
  605. int shmid, void *loaderPrivate);
  606. /**
  607. * Put shm image to drawable (v2)
  608. *
  609. * The original version fixes srcx/y to 0, and expected
  610. * the offset to be adjusted. This version allows src x,y
  611. * to not be included in the offset. This is needed to
  612. * avoid certain overflow checks in the X server, that
  613. * result in lost rendering.
  614. *
  615. * \since 5
  616. */
  617. void (*putImageShm2)(__DRIdrawable *drawable, int op,
  618. int x, int y,
  619. int width, int height, int stride,
  620. int shmid, char *shmaddr, unsigned offset,
  621. void *loaderPrivate);
  622. /**
  623. * get shm image to drawable (v2)
  624. *
  625. * There are some cases where GLX can't use SHM, but DRI
  626. * still tries, we need to get a return type for when to
  627. * fallback to the non-shm path.
  628. *
  629. * \since 6
  630. */
  631. GLboolean (*getImageShm2)(__DRIdrawable *readable,
  632. int x, int y, int width, int height,
  633. int shmid, void *loaderPrivate);
  634. };
  635. /**
  636. * Invalidate loader extension. The presence of this extension
  637. * indicates to the DRI driver that the loader will call invalidate in
  638. * the __DRI2_FLUSH extension, whenever the needs to query for new
  639. * buffers. This means that the DRI driver can drop the polling in
  640. * glViewport().
  641. *
  642. * The extension doesn't provide any functionality, it's only use to
  643. * indicate to the driver that it can use the new semantics. A DRI
  644. * driver can use this to switch between the different semantics or
  645. * just refuse to initialize if this extension isn't present.
  646. */
  647. #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
  648. #define __DRI_USE_INVALIDATE_VERSION 1
  649. typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
  650. struct __DRIuseInvalidateExtensionRec {
  651. __DRIextension base;
  652. };
  653. /**
  654. * The remaining extensions describe driver extensions, immediately
  655. * available interfaces provided by the driver. To start using the
  656. * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
  657. * the extension you need in the array.
  658. */
  659. #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
  660. /**
  661. * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
  662. * suffixed by "_drivername", allowing multiple drivers to be built into one
  663. * library, and also giving the driver the chance to return a variable driver
  664. * extensions struct depending on the driver name being loaded or any other
  665. * system state.
  666. *
  667. * The function prototype is:
  668. *
  669. * const __DRIextension **__driDriverGetExtensions_drivername(void);
  670. */
  671. #define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
  672. /**
  673. * Tokens for __DRIconfig attribs. A number of attributes defined by
  674. * GLX or EGL standards are not in the table, as they must be provided
  675. * by the loader. For example, FBConfig ID or visual ID, drawable type.
  676. */
  677. #define __DRI_ATTRIB_BUFFER_SIZE 1
  678. #define __DRI_ATTRIB_LEVEL 2
  679. #define __DRI_ATTRIB_RED_SIZE 3
  680. #define __DRI_ATTRIB_GREEN_SIZE 4
  681. #define __DRI_ATTRIB_BLUE_SIZE 5
  682. #define __DRI_ATTRIB_LUMINANCE_SIZE 6
  683. #define __DRI_ATTRIB_ALPHA_SIZE 7
  684. #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
  685. #define __DRI_ATTRIB_DEPTH_SIZE 9
  686. #define __DRI_ATTRIB_STENCIL_SIZE 10
  687. #define __DRI_ATTRIB_ACCUM_RED_SIZE 11
  688. #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
  689. #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
  690. #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
  691. #define __DRI_ATTRIB_SAMPLE_BUFFERS 15
  692. #define __DRI_ATTRIB_SAMPLES 16
  693. #define __DRI_ATTRIB_RENDER_TYPE 17
  694. #define __DRI_ATTRIB_CONFIG_CAVEAT 18
  695. #define __DRI_ATTRIB_CONFORMANT 19
  696. #define __DRI_ATTRIB_DOUBLE_BUFFER 20
  697. #define __DRI_ATTRIB_STEREO 21
  698. #define __DRI_ATTRIB_AUX_BUFFERS 22
  699. #define __DRI_ATTRIB_TRANSPARENT_TYPE 23
  700. #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
  701. #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
  702. #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
  703. #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
  704. #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
  705. #define __DRI_ATTRIB_FLOAT_MODE 29
  706. #define __DRI_ATTRIB_RED_MASK 30
  707. #define __DRI_ATTRIB_GREEN_MASK 31
  708. #define __DRI_ATTRIB_BLUE_MASK 32
  709. #define __DRI_ATTRIB_ALPHA_MASK 33
  710. #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
  711. #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
  712. #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
  713. #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
  714. #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
  715. #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
  716. #define __DRI_ATTRIB_SWAP_METHOD 40
  717. #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
  718. #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
  719. #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
  720. #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
  721. #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
  722. #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
  723. #define __DRI_ATTRIB_YINVERTED 47
  724. #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
  725. #define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER 49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */
  726. #define __DRI_ATTRIB_RED_SHIFT 50
  727. #define __DRI_ATTRIB_GREEN_SHIFT 51
  728. #define __DRI_ATTRIB_BLUE_SHIFT 52
  729. #define __DRI_ATTRIB_ALPHA_SHIFT 53
  730. #define __DRI_ATTRIB_YUV_ORDER 54
  731. #define __DRI_ATTRIB_YUV_NUMBER_OF_PLANES 55
  732. #define __DRI_ATTRIB_YUV_SUBSAMPLE 56
  733. #define __DRI_ATTRIB_YUV_DEPTH_RANGE 57
  734. #define __DRI_ATTRIB_YUV_CSC_STANDARD 58
  735. #define __DRI_ATTRIB_YUV_PLANE_BPP 59
  736. #define __DRI_ATTRIB_MAX 60
  737. /* __DRI_ATTRIB_RENDER_TYPE */
  738. #define __DRI_ATTRIB_RGBA_BIT 0x01
  739. #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
  740. #define __DRI_ATTRIB_LUMINANCE_BIT 0x04
  741. #define __DRI_ATTRIB_FLOAT_BIT 0x08
  742. #define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10
  743. #define __DRI_ATTRIB_YUV_BIT 0x20
  744. /* __DRI_ATTRIB_CONFIG_CAVEAT */
  745. #define __DRI_ATTRIB_SLOW_BIT 0x01
  746. #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
  747. /* __DRI_ATTRIB_TRANSPARENT_TYPE */
  748. #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
  749. #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
  750. /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
  751. #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
  752. #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
  753. #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
  754. /* __DRI_ATTRIB_SWAP_METHOD */
  755. /* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define
  756. * the same tokens as GLX. This is because old and current X servers will
  757. * transmit the driconf value grabbed from the AIGLX driver untranslated as
  758. * the GLX fbconfig value. __DRI_ATTRIB_SWAP_NONE is only used by dri drivers
  759. * to signal to the dri core that the driconfig is single-buffer.
  760. */
  761. #define __DRI_ATTRIB_SWAP_NONE 0x0000
  762. #define __DRI_ATTRIB_SWAP_EXCHANGE 0x8061
  763. #define __DRI_ATTRIB_SWAP_COPY 0x8062
  764. #define __DRI_ATTRIB_SWAP_UNDEFINED 0x8063
  765. /* __DRI_ATTRIB_YUV_ORDER */
  766. #define __DRI_ATTRIB_YUV_ORDER_NONE 0x0
  767. #define __DRI_ATTRIB_YUV_ORDER_YUV_BIT 0x1
  768. #define __DRI_ATTRIB_YUV_ORDER_YVU_BIT 0x2
  769. #define __DRI_ATTRIB_YUV_ORDER_YUYV_BIT 0x4
  770. #define __DRI_ATTRIB_YUV_ORDER_UYVY_BIT 0x8
  771. #define __DRI_ATTRIB_YUV_ORDER_YVYU_BIT 0x10
  772. #define __DRI_ATTRIB_YUV_ORDER_VYUY_BIT 0x20
  773. #define __DRI_ATTRIB_YUV_ORDER_AYUV_BIT 0x40
  774. /* __DRI_ATTRIB_YUV_SUBSAMPLE */
  775. #define __DRI_ATTRIB_YUV_SUBSAMPLE_NONE 0x0
  776. #define __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_0_BIT 0x1
  777. #define __DRI_ATTRIB_YUV_SUBSAMPLE_4_2_2_BIT 0x2
  778. #define __DRI_ATTRIB_YUV_SUBSAMPLE_4_4_4_BIT 0x4
  779. /* __DRI_ATTRIB_YUV_DEPTH_RANGE */
  780. #define __DRI_ATTRIB_YUV_DEPTH_RANGE_NONE 0x0
  781. #define __DRI_ATTRIB_YUV_DEPTH_RANGE_LIMITED_BIT 0x1
  782. #define __DRI_ATTRIB_YUV_DEPTH_RANGE_FULL_BIT 0x2
  783. /* __DRI_ATTRIB_YUV_CSC_STANDARD */
  784. #define __DRI_ATTRIB_YUV_CSC_STANDARD_NONE 0x0
  785. #define __DRI_ATTRIB_YUV_CSC_STANDARD_601_BIT 0x1
  786. #define __DRI_ATTRIB_YUV_CSC_STANDARD_709_BIT 0x2
  787. #define __DRI_ATTRIB_YUV_CSC_STANDARD_2020_BIT 0x4
  788. /* __DRI_ATTRIB_YUV_PLANE_BPP */
  789. #define __DRI_ATTRIB_YUV_PLANE_BPP_NONE 0x0
  790. #define __DRI_ATTRIB_YUV_PLANE_BPP_0_BIT 0x1
  791. #define __DRI_ATTRIB_YUV_PLANE_BPP_8_BIT 0x2
  792. #define __DRI_ATTRIB_YUV_PLANE_BPP_10_BIT 0x4
  793. /**
  794. * This extension defines the core DRI functionality.
  795. *
  796. * Version >= 2 indicates that getConfigAttrib with __DRI_ATTRIB_SWAP_METHOD
  797. * returns a reliable value.
  798. */
  799. #define __DRI_CORE "DRI_Core"
  800. #define __DRI_CORE_VERSION 2
  801. struct __DRIcoreExtensionRec {
  802. __DRIextension base;
  803. __DRIscreen *(*createNewScreen)(int screen, int fd,
  804. unsigned int sarea_handle,
  805. const __DRIextension **extensions,
  806. const __DRIconfig ***driverConfigs,
  807. void *loaderPrivate);
  808. void (*destroyScreen)(__DRIscreen *screen);
  809. const __DRIextension **(*getExtensions)(__DRIscreen *screen);
  810. int (*getConfigAttrib)(const __DRIconfig *config,
  811. unsigned int attrib,
  812. unsigned int *value);
  813. int (*indexConfigAttrib)(const __DRIconfig *config, int index,
  814. unsigned int *attrib, unsigned int *value);
  815. __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
  816. const __DRIconfig *config,
  817. unsigned int drawable_id,
  818. unsigned int head,
  819. void *loaderPrivate);
  820. void (*destroyDrawable)(__DRIdrawable *drawable);
  821. void (*swapBuffers)(__DRIdrawable *drawable);
  822. __DRIcontext *(*createNewContext)(__DRIscreen *screen,
  823. const __DRIconfig *config,
  824. __DRIcontext *shared,
  825. void *loaderPrivate);
  826. int (*copyContext)(__DRIcontext *dest,
  827. __DRIcontext *src,
  828. unsigned long mask);
  829. void (*destroyContext)(__DRIcontext *context);
  830. int (*bindContext)(__DRIcontext *ctx,
  831. __DRIdrawable *pdraw,
  832. __DRIdrawable *pread);
  833. int (*unbindContext)(__DRIcontext *ctx);
  834. };
  835. /**
  836. * Stored version of some component (i.e., server-side DRI module, kernel-side
  837. * DRM, etc.).
  838. *
  839. * \todo
  840. * There are several data structures that explicitly store a major version,
  841. * minor version, and patch level. These structures should be modified to
  842. * have a \c __DRIversionRec instead.
  843. */
  844. struct __DRIversionRec {
  845. int major; /**< Major version number. */
  846. int minor; /**< Minor version number. */
  847. int patch; /**< Patch-level. */
  848. };
  849. /**
  850. * Framebuffer information record. Used by libGL to communicate information
  851. * about the framebuffer to the driver's \c __driCreateNewScreen function.
  852. *
  853. * In XFree86, most of this information is derrived from data returned by
  854. * calling \c XF86DRIGetDeviceInfo.
  855. *
  856. * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
  857. * __driUtilCreateNewScreen CallCreateNewScreen
  858. *
  859. * \bug This structure could be better named.
  860. */
  861. struct __DRIframebufferRec {
  862. unsigned char *base; /**< Framebuffer base address in the CPU's
  863. * address space. This value is calculated by
  864. * calling \c drmMap on the framebuffer handle
  865. * returned by \c XF86DRIGetDeviceInfo (or a
  866. * similar function).
  867. */
  868. int size; /**< Framebuffer size, in bytes. */
  869. int stride; /**< Number of bytes from one line to the next. */
  870. int width; /**< Pixel width of the framebuffer. */
  871. int height; /**< Pixel height of the framebuffer. */
  872. int dev_priv_size; /**< Size of the driver's dev-priv structure. */
  873. void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
  874. };
  875. /**
  876. * This extension provides alternative screen, drawable and context
  877. * constructors for legacy DRI functionality. This is used in
  878. * conjunction with the core extension.
  879. */
  880. #define __DRI_LEGACY "DRI_Legacy"
  881. #define __DRI_LEGACY_VERSION 1
  882. struct __DRIlegacyExtensionRec {
  883. __DRIextension base;
  884. __DRIscreen *(*createNewScreen)(int screen,
  885. const __DRIversion *ddx_version,
  886. const __DRIversion *dri_version,
  887. const __DRIversion *drm_version,
  888. const __DRIframebuffer *frame_buffer,
  889. void *pSAREA, int fd,
  890. const __DRIextension **extensions,
  891. const __DRIconfig ***driver_configs,
  892. void *loaderPrivate);
  893. __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
  894. const __DRIconfig *config,
  895. drm_drawable_t hwDrawable,
  896. int renderType, const int *attrs,
  897. void *loaderPrivate);
  898. __DRIcontext *(*createNewContext)(__DRIscreen *screen,
  899. const __DRIconfig *config,
  900. int render_type,
  901. __DRIcontext *shared,
  902. drm_context_t hwContext,
  903. void *loaderPrivate);
  904. };
  905. /**
  906. * This extension provides alternative screen, drawable and context
  907. * constructors for swrast DRI functionality. This is used in
  908. * conjunction with the core extension.
  909. */
  910. #define __DRI_SWRAST "DRI_SWRast"
  911. #define __DRI_SWRAST_VERSION 4
  912. struct __DRIswrastExtensionRec {
  913. __DRIextension base;
  914. __DRIscreen *(*createNewScreen)(int screen,
  915. const __DRIextension **extensions,
  916. const __DRIconfig ***driver_configs,
  917. void *loaderPrivate);
  918. __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
  919. const __DRIconfig *config,
  920. void *loaderPrivate);
  921. /* Since version 2 */
  922. __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
  923. int api,
  924. const __DRIconfig *config,
  925. __DRIcontext *shared,
  926. void *data);
  927. /**
  928. * Create a context for a particular API with a set of attributes
  929. *
  930. * \since version 3
  931. *
  932. * \sa __DRIdri2ExtensionRec::createContextAttribs
  933. */
  934. __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
  935. int api,
  936. const __DRIconfig *config,
  937. __DRIcontext *shared,
  938. unsigned num_attribs,
  939. const uint32_t *attribs,
  940. unsigned *error,
  941. void *loaderPrivate);
  942. /**
  943. * createNewScreen() with the driver extensions passed in.
  944. *
  945. * \since version 4
  946. */
  947. __DRIscreen *(*createNewScreen2)(int screen,
  948. const __DRIextension **loader_extensions,
  949. const __DRIextension **driver_extensions,
  950. const __DRIconfig ***driver_configs,
  951. void *loaderPrivate);
  952. };
  953. /** Common DRI function definitions, shared among DRI2 and Image extensions
  954. */
  955. typedef __DRIscreen *
  956. (*__DRIcreateNewScreen2Func)(int screen, int fd,
  957. const __DRIextension **extensions,
  958. const __DRIextension **driver_extensions,
  959. const __DRIconfig ***driver_configs,
  960. void *loaderPrivate);
  961. typedef __DRIdrawable *
  962. (*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
  963. const __DRIconfig *config,
  964. void *loaderPrivate);
  965. typedef __DRIcontext *
  966. (*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
  967. int api,
  968. const __DRIconfig *config,
  969. __DRIcontext *shared,
  970. unsigned num_attribs,
  971. const uint32_t *attribs,
  972. unsigned *error,
  973. void *loaderPrivate);
  974. typedef unsigned int
  975. (*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
  976. /**
  977. * DRI2 Loader extension.
  978. */
  979. #define __DRI_BUFFER_FRONT_LEFT 0
  980. #define __DRI_BUFFER_BACK_LEFT 1
  981. #define __DRI_BUFFER_FRONT_RIGHT 2
  982. #define __DRI_BUFFER_BACK_RIGHT 3
  983. #define __DRI_BUFFER_DEPTH 4
  984. #define __DRI_BUFFER_STENCIL 5
  985. #define __DRI_BUFFER_ACCUM 6
  986. #define __DRI_BUFFER_FAKE_FRONT_LEFT 7
  987. #define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
  988. #define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
  989. #define __DRI_BUFFER_HIZ 10
  990. /* Inofficial and for internal use. Increase when adding a new buffer token. */
  991. #define __DRI_BUFFER_COUNT 11
  992. struct __DRIbufferRec {
  993. unsigned int attachment;
  994. unsigned int name;
  995. unsigned int pitch;
  996. unsigned int cpp;
  997. unsigned int flags;
  998. };
  999. #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
  1000. #define __DRI_DRI2_LOADER_VERSION 6
  1001. enum dri_loader_cap {
  1002. /* Whether the loader handles RGBA channel ordering correctly. If not,
  1003. * only BGRA ordering can be exposed.
  1004. */
  1005. DRI_LOADER_CAP_RGBA_ORDERING,
  1006. DRI_LOADER_CAP_FP16,
  1007. DRI_LOADER_CAP_YUV_SURFACE_IMG = 0x7001,
  1008. };
  1009. struct __DRIdri2LoaderExtensionRec {
  1010. __DRIextension base;
  1011. __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
  1012. int *width, int *height,
  1013. unsigned int *attachments, int count,
  1014. int *out_count, void *loaderPrivate);
  1015. /**
  1016. * Flush pending front-buffer rendering
  1017. *
  1018. * Any rendering that has been performed to the
  1019. * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
  1020. * \c __DRI_BUFFER_FRONT_LEFT.
  1021. *
  1022. * \param driDrawable Drawable whose front-buffer is to be flushed
  1023. * \param loaderPrivate Loader's private data that was previously passed
  1024. * into __DRIdri2ExtensionRec::createNewDrawable
  1025. *
  1026. * \since 2
  1027. */
  1028. void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
  1029. /**
  1030. * Get list of buffers from the server
  1031. *
  1032. * Gets a list of buffer for the specified set of attachments. Unlike
  1033. * \c ::getBuffers, this function takes a list of attachments paired with
  1034. * opaque \c unsigned \c int value describing the format of the buffer.
  1035. * It is the responsibility of the caller to know what the service that
  1036. * allocates the buffers will expect to receive for the format.
  1037. *
  1038. * \param driDrawable Drawable whose buffers are being queried.
  1039. * \param width Output where the width of the buffers is stored.
  1040. * \param height Output where the height of the buffers is stored.
  1041. * \param attachments List of pairs of attachment ID and opaque format
  1042. * requested for the drawable.
  1043. * \param count Number of attachment / format pairs stored in
  1044. * \c attachments.
  1045. * \param loaderPrivate Loader's private data that was previously passed
  1046. * into __DRIdri2ExtensionRec::createNewDrawable.
  1047. *
  1048. * \since 3
  1049. */
  1050. __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
  1051. int *width, int *height,
  1052. unsigned int *attachments, int count,
  1053. int *out_count, void *loaderPrivate);
  1054. /**
  1055. * Return a loader capability value. If the loader doesn't know the enum,
  1056. * it will return 0.
  1057. *
  1058. * \param loaderPrivate The last parameter of createNewScreen or
  1059. * createNewScreen2.
  1060. * \param cap See the enum.
  1061. *
  1062. * \since 4
  1063. */
  1064. unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
  1065. /**
  1066. * Clean up any loader state associated with an image.
  1067. *
  1068. * \param loaderPrivate Loader's private data that was previously passed
  1069. * into a __DRIimageExtensionRec::createImage function
  1070. * \since 5
  1071. */
  1072. void (*destroyLoaderImageState)(void *loaderPrivate);
  1073. /**
  1074. * Get the display FD
  1075. *
  1076. * Get the FD of the display device.
  1077. *
  1078. * \param loaderPrivate The last parameter of createNewScreen or
  1079. * createNewScreen2.
  1080. * \since 6
  1081. */
  1082. int (*getDisplayFD)(void *loaderPrivate);
  1083. };
  1084. /**
  1085. * This extension provides alternative screen, drawable and context
  1086. * constructors for DRI2.
  1087. */
  1088. #define __DRI_DRI2 "DRI_DRI2"
  1089. #define __DRI_DRI2_VERSION 4
  1090. #define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
  1091. #define __DRI_API_GLES 1 /**< OpenGL ES 1.x */
  1092. #define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */
  1093. #define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
  1094. #define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */
  1095. #define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
  1096. #define __DRI_CTX_ATTRIB_MINOR_VERSION 1
  1097. #define __DRI_CTX_ATTRIB_FLAGS 2
  1098. /**
  1099. * \requires __DRI2_ROBUSTNESS.
  1100. */
  1101. #define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
  1102. #define __DRI_CTX_FLAG_DEBUG 0x00000001
  1103. #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
  1104. /**
  1105. * \requires __DRI2_ROBUSTNESS.
  1106. */
  1107. #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004
  1108. /**
  1109. * \requires __DRI2_NO_ERROR.
  1110. *
  1111. */
  1112. #define __DRI_CTX_FLAG_NO_ERROR 0x00000008
  1113. /**
  1114. * \name Context reset strategies.
  1115. */
  1116. /*@{*/
  1117. #define __DRI_CTX_RESET_NO_NOTIFICATION 0
  1118. #define __DRI_CTX_RESET_LOSE_CONTEXT 1
  1119. /*@}*/
  1120. #define __DRI_CTX_ATTRIB_PRIORITY 4
  1121. #define __DRI_CTX_PRIORITY_LOW 0
  1122. #define __DRI_CTX_PRIORITY_MEDIUM 1
  1123. #define __DRI_CTX_PRIORITY_HIGH 2
  1124. /**
  1125. * \name Context release behaviors.
  1126. */
  1127. /*@{*/
  1128. #define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR 5
  1129. #define __DRI_CTX_RELEASE_BEHAVIOR_NONE 0
  1130. #define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH 1
  1131. /*@}*/
  1132. /**
  1133. * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
  1134. */
  1135. /*@{*/
  1136. /** Success! */
  1137. #define __DRI_CTX_ERROR_SUCCESS 0
  1138. /** Memory allocation failure */
  1139. #define __DRI_CTX_ERROR_NO_MEMORY 1
  1140. /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
  1141. #define __DRI_CTX_ERROR_BAD_API 2
  1142. /** Client requested an API version that the driver can't do. */
  1143. #define __DRI_CTX_ERROR_BAD_VERSION 3
  1144. /** Client requested a flag or combination of flags the driver can't do. */
  1145. #define __DRI_CTX_ERROR_BAD_FLAG 4
  1146. /** Client requested an attribute the driver doesn't understand. */
  1147. #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
  1148. /** Client requested a flag the driver doesn't understand. */
  1149. #define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
  1150. /*@}*/
  1151. struct __DRIdri2ExtensionRec {
  1152. __DRIextension base;
  1153. __DRIscreen *(*createNewScreen)(int screen, int fd,
  1154. const __DRIextension **extensions,
  1155. const __DRIconfig ***driver_configs,
  1156. void *loaderPrivate);
  1157. __DRIcreateNewDrawableFunc createNewDrawable;
  1158. __DRIcontext *(*createNewContext)(__DRIscreen *screen,
  1159. const __DRIconfig *config,
  1160. __DRIcontext *shared,
  1161. void *loaderPrivate);
  1162. /* Since version 2 */
  1163. __DRIgetAPIMaskFunc getAPIMask;
  1164. __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
  1165. int api,
  1166. const __DRIconfig *config,
  1167. __DRIcontext *shared,
  1168. void *data);
  1169. __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
  1170. unsigned int attachment,
  1171. unsigned int format,
  1172. int width,
  1173. int height);
  1174. void (*releaseBuffer)(__DRIscreen *screen,
  1175. __DRIbuffer *buffer);
  1176. /**
  1177. * Create a context for a particular API with a set of attributes
  1178. *
  1179. * \since version 3
  1180. *
  1181. * \sa __DRIswrastExtensionRec::createContextAttribs
  1182. */
  1183. __DRIcreateContextAttribsFunc createContextAttribs;
  1184. /**
  1185. * createNewScreen with the driver's extension list passed in.
  1186. *
  1187. * \since version 4
  1188. */
  1189. __DRIcreateNewScreen2Func createNewScreen2;
  1190. };
  1191. /**
  1192. * This extension provides functionality to enable various EGLImage
  1193. * extensions.
  1194. */
  1195. #define __DRI_IMAGE "DRI_IMAGE"
  1196. #define __DRI_IMAGE_VERSION 18
  1197. /**
  1198. * These formats correspond to the similarly named MESA_FORMAT_*
  1199. * tokens, except in the native endian of the CPU. For example, on
  1200. * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
  1201. * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
  1202. *
  1203. * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
  1204. * by the driver (YUV planar formats) but serve as a base image for
  1205. * creating sub-images for the different planes within the image.
  1206. *
  1207. * R8, GR88 and NONE should not be used with createImageFromName or
  1208. * createImage, and are returned by query from sub images created with
  1209. * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
  1210. */
  1211. #define __DRI_IMAGE_FORMAT_RGB565 0x1001
  1212. #define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
  1213. #define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
  1214. #define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
  1215. #define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
  1216. #define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
  1217. #define __DRI_IMAGE_FORMAT_GR88 0x1007
  1218. #define __DRI_IMAGE_FORMAT_NONE 0x1008
  1219. #define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
  1220. #define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
  1221. #define __DRI_IMAGE_FORMAT_SARGB8 0x100b
  1222. #define __DRI_IMAGE_FORMAT_ARGB1555 0x100c
  1223. #define __DRI_IMAGE_FORMAT_R16 0x100d
  1224. #define __DRI_IMAGE_FORMAT_GR1616 0x100e
  1225. #define __DRI_IMAGE_FORMAT_YUYV 0x100f
  1226. #define __DRI_IMAGE_FORMAT_XBGR2101010 0x1010
  1227. #define __DRI_IMAGE_FORMAT_ABGR2101010 0x1011
  1228. #define __DRI_IMAGE_FORMAT_SABGR8 0x1012
  1229. #define __DRI_IMAGE_FORMAT_UYVY 0x1013
  1230. #define __DRI_IMAGE_FORMAT_XBGR16161616F 0x1014
  1231. #define __DRI_IMAGE_FORMAT_ABGR16161616F 0x1015
  1232. #define __DRI_IMAGE_FORMAT_SXRGB8 0x1016
  1233. #define __DRI_IMAGE_FORMAT_ARGB4444 0x1017
  1234. #define __DRI_IMAGE_FORMAT_YVU444_PACK10_IMG 0x1018
  1235. #define __DRI_IMAGE_FORMAT_BGR888 0x1019
  1236. #define __DRI_IMAGE_FORMAT_NV12 0x101a
  1237. #define __DRI_IMAGE_FORMAT_NV21 0x101b
  1238. #define __DRI_IMAGE_FORMAT_YU12 0x101c
  1239. #define __DRI_IMAGE_FORMAT_YV12 0x101d
  1240. #define __DRI_IMAGE_USE_SHARE 0x0001
  1241. #define __DRI_IMAGE_USE_SCANOUT 0x0002
  1242. #define __DRI_IMAGE_USE_CURSOR 0x0004 /* Deprecated */
  1243. #define __DRI_IMAGE_USE_LINEAR 0x0008
  1244. /* The buffer will only be read by an external process after SwapBuffers,
  1245. * in contrary to gbm buffers, front buffers and fake front buffers, which
  1246. * could be read after a flush."
  1247. */
  1248. #define __DRI_IMAGE_USE_BACKBUFFER 0x0010
  1249. #define __DRI_IMAGE_USE_PROTECTED 0x0020
  1250. #define __DRI_IMAGE_TRANSFER_READ 0x1
  1251. #define __DRI_IMAGE_TRANSFER_WRITE 0x2
  1252. #define __DRI_IMAGE_TRANSFER_READ_WRITE \
  1253. (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)
  1254. /**
  1255. * Extra fourcc formats used internally to Mesa with createImageFromNames.
  1256. * The externally-available fourccs are defined by drm_fourcc.h (DRM_FORMAT_*)
  1257. * and WL_DRM_FORMAT_* from wayland_drm.h.
  1258. *
  1259. * \since 5
  1260. */
  1261. #define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258
  1262. #define __DRI_IMAGE_FOURCC_SABGR8888 0x84324258
  1263. #define __DRI_IMAGE_FOURCC_SXRGB8888 0x85324258
  1264. #define __DRI_IMAGE_FOURCC_SBGR888 0xff324742
  1265. /**
  1266. * Queryable on images created by createImageFromNames.
  1267. *
  1268. * RGB and RGBA are may be usable directly as images but its still
  1269. * recommended to call fromPlanar with plane == 0.
  1270. *
  1271. * Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create
  1272. * usable sub-images, sampling from images return raw YUV data and
  1273. * color conversion needs to be done in the shader.
  1274. *
  1275. * \since 5
  1276. */
  1277. #define __DRI_IMAGE_COMPONENTS_RGB 0x3001
  1278. #define __DRI_IMAGE_COMPONENTS_RGBA 0x3002
  1279. #define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
  1280. #define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
  1281. #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
  1282. #define __DRI_IMAGE_COMPONENTS_R 0x3006
  1283. #define __DRI_IMAGE_COMPONENTS_RG 0x3007
  1284. #define __DRI_IMAGE_COMPONENTS_Y_UXVX 0x3008
  1285. #define __DRI_IMAGE_COMPONENTS_AYUV 0x3009
  1286. #define __DRI_IMAGE_COMPONENTS_XYUV 0x300A
  1287. #define __DRI_IMAGE_COMPONENTS_EXTERNAL 0x300B
  1288. /**
  1289. * queryImage attributes
  1290. */
  1291. #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
  1292. #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
  1293. #define __DRI_IMAGE_ATTRIB_NAME 0x2002
  1294. #define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
  1295. #define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */
  1296. #define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005
  1297. #define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */
  1298. #define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions
  1299. * 7+. Each query will return a
  1300. * new fd. */
  1301. #define __DRI_IMAGE_ATTRIB_FOURCC 0x2008 /* available in versions 11 */
  1302. #define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */
  1303. #define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
  1304. #define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */
  1305. #define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */
  1306. enum __DRIYUVColorSpace {
  1307. __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
  1308. __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
  1309. __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
  1310. __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
  1311. };
  1312. enum __DRISampleRange {
  1313. __DRI_YUV_RANGE_UNDEFINED = 0,
  1314. __DRI_YUV_FULL_RANGE = 0x3282,
  1315. __DRI_YUV_NARROW_RANGE = 0x3283
  1316. };
  1317. enum __DRIChromaSiting {
  1318. __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
  1319. __DRI_YUV_CHROMA_SITING_0 = 0x3284,
  1320. __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
  1321. };
  1322. /**
  1323. * \name Reasons that __DRIimageExtensionRec::createImageFromTexture or
  1324. * __DRIimageExtensionRec::createImageFromDmaBufs might fail
  1325. */
  1326. /*@{*/
  1327. /** Success! */
  1328. #define __DRI_IMAGE_ERROR_SUCCESS 0
  1329. /** Memory allocation failure */
  1330. #define __DRI_IMAGE_ERROR_BAD_ALLOC 1
  1331. /** Client requested an invalid attribute */
  1332. #define __DRI_IMAGE_ERROR_BAD_MATCH 2
  1333. /** Client requested an invalid texture object */
  1334. #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
  1335. /** Client requested an invalid pitch and/or offset */
  1336. #define __DRI_IMAGE_ERROR_BAD_ACCESS 4
  1337. /*@}*/
  1338. /**
  1339. * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
  1340. */
  1341. /*@{*/
  1342. #define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
  1343. #define __DRI_IMAGE_CAP_PRIME_IMPORT 0x2000
  1344. #define __DRI_IMAGE_CAP_PRIME_EXPORT 0x4000
  1345. /*@}*/
  1346. /**
  1347. * blitImage flags
  1348. */
  1349. #define __BLIT_FLAG_FLUSH 0x0001
  1350. #define __BLIT_FLAG_FINISH 0x0002
  1351. /**
  1352. * Flags for createImageFromDmaBufs3
  1353. */
  1354. #define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001
  1355. /**
  1356. * queryDmaBufFormatModifierAttribs attributes
  1357. */
  1358. /* Available in version 16 */
  1359. #define __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT 0x0001
  1360. typedef struct __DRIimageRec __DRIimage;
  1361. typedef struct __DRIimageExtensionRec __DRIimageExtension;
  1362. struct __DRIimageExtensionRec {
  1363. __DRIextension base;
  1364. __DRIimage *(*createImageFromName)(__DRIscreen *screen,
  1365. int width, int height, int format,
  1366. int name, int pitch,
  1367. void *loaderPrivate);
  1368. /* Deprecated since version 17; see createImageFromRenderbuffer2 */
  1369. __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
  1370. int renderbuffer,
  1371. void *loaderPrivate);
  1372. void (*destroyImage)(__DRIimage *image);
  1373. __DRIimage *(*createImage)(__DRIscreen *screen,
  1374. int width, int height, int format,
  1375. unsigned int use,
  1376. void *loaderPrivate);
  1377. GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
  1378. /**
  1379. * The new __DRIimage will share the content with the old one, see dup(2).
  1380. */
  1381. __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
  1382. /**
  1383. * Validate that a __DRIimage can be used a certain way.
  1384. *
  1385. * \since 2
  1386. */
  1387. GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
  1388. /**
  1389. * Unlike createImageFromName __DRI_IMAGE_FORMAT is not used but instead
  1390. * DRM_FORMAT_*, and strides are in bytes not pixels. Stride is
  1391. * also per block and not per pixel (for non-RGB, see gallium blocks).
  1392. *
  1393. * \since 5
  1394. */
  1395. __DRIimage *(*createImageFromNames)(__DRIscreen *screen,
  1396. int width, int height, int fourcc,
  1397. int *names, int num_names,
  1398. int *strides, int *offsets,
  1399. void *loaderPrivate);
  1400. /**
  1401. * Create an image out of a sub-region of a parent image. This
  1402. * entry point lets us create individual __DRIimages for different
  1403. * planes in a planar buffer (typically yuv), for example. While a
  1404. * sub-image shares the underlying buffer object with the parent
  1405. * image and other sibling sub-images, the life times of parent and
  1406. * sub-images are not dependent. Destroying the parent or a
  1407. * sub-image doesn't affect other images. The underlying buffer
  1408. * object is free when no __DRIimage remains that references it.
  1409. *
  1410. * Sub-images may overlap, but rendering to overlapping sub-images
  1411. * is undefined.
  1412. *
  1413. * \since 5
  1414. */
  1415. __DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
  1416. void *loaderPrivate);
  1417. /**
  1418. * Create image from texture.
  1419. *
  1420. * \since 6
  1421. */
  1422. __DRIimage *(*createImageFromTexture)(__DRIcontext *context,
  1423. int target,
  1424. unsigned texture,
  1425. int depth,
  1426. int level,
  1427. unsigned *error,
  1428. void *loaderPrivate);
  1429. /**
  1430. * Like createImageFromNames, but takes a prime fd instead.
  1431. *
  1432. * \since 7
  1433. */
  1434. __DRIimage *(*createImageFromFds)(__DRIscreen *screen,
  1435. int width, int height, int fourcc,
  1436. int *fds, int num_fds,
  1437. int *strides, int *offsets,
  1438. void *loaderPrivate);
  1439. /**
  1440. * Like createImageFromFds, but takes additional attributes.
  1441. *
  1442. * For EGL_EXT_image_dma_buf_import.
  1443. *
  1444. * \since 8
  1445. */
  1446. __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
  1447. int width, int height, int fourcc,
  1448. int *fds, int num_fds,
  1449. int *strides, int *offsets,
  1450. enum __DRIYUVColorSpace color_space,
  1451. enum __DRISampleRange sample_range,
  1452. enum __DRIChromaSiting horiz_siting,
  1453. enum __DRIChromaSiting vert_siting,
  1454. unsigned *error,
  1455. void *loaderPrivate);
  1456. /**
  1457. * Blit a part of a __DRIimage to another and flushes
  1458. *
  1459. * flush_flag:
  1460. * 0: no flush
  1461. * __BLIT_FLAG_FLUSH: flush after the blit operation
  1462. * __BLIT_FLAG_FINISH: flush and wait the blit finished
  1463. *
  1464. * \since 9
  1465. */
  1466. void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
  1467. int dstx0, int dsty0, int dstwidth, int dstheight,
  1468. int srcx0, int srcy0, int srcwidth, int srcheight,
  1469. int flush_flag);
  1470. /**
  1471. * Query for general capabilities of the driver that concern
  1472. * buffer sharing and image importing.
  1473. *
  1474. * \since 10
  1475. */
  1476. int (*getCapabilities)(__DRIscreen *screen);
  1477. /**
  1478. * Returns a map of the specified region of a __DRIimage for the specified usage.
  1479. *
  1480. * flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the
  1481. * mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ
  1482. * is not included in the flags, the buffer content at map time is
  1483. * undefined. Users wanting to modify the mapping must include
  1484. * __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not
  1485. * included, behaviour when writing the mapping is undefined.
  1486. *
  1487. * Returns the byte stride in *stride, and an opaque pointer to data
  1488. * tracking the mapping in **data, which must be passed to unmapImage().
  1489. *
  1490. * \since 12
  1491. */
  1492. void *(*mapImage)(__DRIcontext *context, __DRIimage *image,
  1493. int x0, int y0, int width, int height,
  1494. unsigned int flags, int *stride, void **data);
  1495. /**
  1496. * Unmap a previously mapped __DRIimage
  1497. *
  1498. * \since 12
  1499. */
  1500. void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);
  1501. /**
  1502. * Creates an image with implementation's favorite modifiers.
  1503. *
  1504. * This acts like createImage except there is a list of modifiers passed in
  1505. * which the implementation may selectively use to create the DRIimage. The
  1506. * result should be the implementation selects one modifier (perhaps it would
  1507. * hold on to a few and later pick).
  1508. *
  1509. * The created image should be destroyed with destroyImage().
  1510. *
  1511. * Returns the new DRIimage. The chosen modifier can be obtained later on
  1512. * and passed back to things like the kernel's AddFB2 interface.
  1513. *
  1514. * \sa __DRIimageRec::createImage
  1515. *
  1516. * \since 14
  1517. */
  1518. __DRIimage *(*createImageWithModifiers)(__DRIscreen *screen,
  1519. int width, int height, int format,
  1520. const uint64_t *modifiers,
  1521. const unsigned int modifier_count,
  1522. void *loaderPrivate);
  1523. /*
  1524. * Like createImageFromDmaBufs, but takes also format modifiers.
  1525. *
  1526. * For EGL_EXT_image_dma_buf_import_modifiers.
  1527. *
  1528. * \since 15
  1529. */
  1530. __DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen,
  1531. int width, int height, int fourcc,
  1532. uint64_t modifier,
  1533. int *fds, int num_fds,
  1534. int *strides, int *offsets,
  1535. enum __DRIYUVColorSpace color_space,
  1536. enum __DRISampleRange sample_range,
  1537. enum __DRIChromaSiting horiz_siting,
  1538. enum __DRIChromaSiting vert_siting,
  1539. unsigned *error,
  1540. void *loaderPrivate);
  1541. /*
  1542. * dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers.
  1543. *
  1544. * \param max Maximum number of formats that can be accomodated into
  1545. * \param formats. If zero, no formats are returned -
  1546. * instead, the driver returns the total number of
  1547. * supported dmabuf formats in \param count.
  1548. * \param formats Buffer to fill formats into.
  1549. * \param count Count of formats returned, or, total number of
  1550. * supported formats in case \param max is zero.
  1551. *
  1552. * Returns true on success.
  1553. *
  1554. * \since 15
  1555. */
  1556. GLboolean (*queryDmaBufFormats)(__DRIscreen *screen, int max,
  1557. int *formats, int *count);
  1558. /*
  1559. * dmabuf format modifier query for a given format to support
  1560. * EGL_EXT_image_dma_buf_import_modifiers.
  1561. *
  1562. * \param fourcc The format to query modifiers for. If this format
  1563. * is not supported by the driver, return false.
  1564. * \param max Maximum number of modifiers that can be accomodated in
  1565. * \param modifiers. If zero, no modifiers are returned -
  1566. * instead, the driver returns the total number of
  1567. * modifiers for \param format in \param count.
  1568. * \param modifiers Buffer to fill modifiers into.
  1569. * \param count Count of the modifiers returned, or, total number of
  1570. * supported modifiers for \param fourcc in case
  1571. * \param max is zero.
  1572. *
  1573. * Returns true upon success.
  1574. *
  1575. * \since 15
  1576. */
  1577. GLboolean (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc,
  1578. int max, uint64_t *modifiers,
  1579. unsigned int *external_only,
  1580. int *count);
  1581. /**
  1582. * dmabuf format modifier attribute query for a given format and modifier.
  1583. *
  1584. * \param fourcc The format to query. If this format is not supported by
  1585. * the driver, return false.
  1586. * \param modifier The modifier to query. If this format+modifier is not
  1587. * supported by the driver, return false.
  1588. * \param attrib The __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB to query.
  1589. * \param value A pointer to where to store the result of the query.
  1590. *
  1591. * Returns true upon success.
  1592. *
  1593. * \since 16
  1594. */
  1595. GLboolean (*queryDmaBufFormatModifierAttribs)(__DRIscreen *screen,
  1596. uint32_t fourcc, uint64_t modifier,
  1597. int attrib, uint64_t *value);
  1598. /**
  1599. * Create a DRI image from the given renderbuffer.
  1600. *
  1601. * \param context the current DRI context
  1602. * \param renderbuffer the GL name of the renderbuffer
  1603. * \param loaderPrivate for callbacks into the loader related to the image
  1604. * \param error will be set to one of __DRI_IMAGE_ERROR_xxx
  1605. * \return the newly created image on success, or NULL otherwise
  1606. *
  1607. * \since 17
  1608. */
  1609. __DRIimage *(*createImageFromRenderbuffer2)(__DRIcontext *context,
  1610. int renderbuffer,
  1611. void *loaderPrivate,
  1612. unsigned *error);
  1613. /*
  1614. * Like createImageFromDmaBufs2, but with an added flags parameter.
  1615. *
  1616. * See __DRI_IMAGE_*_FLAG for valid definitions of flags.
  1617. *
  1618. * \since 18
  1619. */
  1620. __DRIimage *(*createImageFromDmaBufs3)(__DRIscreen *screen,
  1621. int width, int height, int fourcc,
  1622. uint64_t modifier,
  1623. int *fds, int num_fds,
  1624. int *strides, int *offsets,
  1625. enum __DRIYUVColorSpace color_space,
  1626. enum __DRISampleRange sample_range,
  1627. enum __DRIChromaSiting horiz_siting,
  1628. enum __DRIChromaSiting vert_siting,
  1629. uint32_t flags,
  1630. unsigned *error,
  1631. void *loaderPrivate);
  1632. /**
  1633. * Support for experimental EGL_CL_IMAGE_IMG.
  1634. * Like createImageFromTexture, but from a buffer, the contents
  1635. * of which depend on the target.
  1636. *
  1637. * \since 8
  1638. */
  1639. __DRIimage *(*createImageFromBuffer)(__DRIcontext *context,
  1640. int target,
  1641. void *buffer,
  1642. unsigned *error,
  1643. void *loaderPrivate);
  1644. };
  1645. /**
  1646. * This extension must be implemented by the loader and passed to the
  1647. * driver at screen creation time. The EGLImage entry points in the
  1648. * various client APIs take opaque EGLImage handles and use this
  1649. * extension to map them to a __DRIimage. At version 1, this
  1650. * extensions allows mapping EGLImage pointers to __DRIimage pointers,
  1651. * but future versions could support other EGLImage-like, opaque types
  1652. * with new lookup functions.
  1653. */
  1654. #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
  1655. #define __DRI_IMAGE_LOOKUP_VERSION 1
  1656. typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
  1657. struct __DRIimageLookupExtensionRec {
  1658. __DRIextension base;
  1659. __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
  1660. void *loaderPrivate);
  1661. };
  1662. /**
  1663. * This extension allows for common DRI2 options
  1664. */
  1665. #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
  1666. #define __DRI2_CONFIG_QUERY_VERSION 2
  1667. typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
  1668. struct __DRI2configQueryExtensionRec {
  1669. __DRIextension base;
  1670. int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);
  1671. int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
  1672. int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
  1673. int (*configQuerys)(__DRIscreen *screen, const char *var, char **val);
  1674. };
  1675. /**
  1676. * Robust context driver extension.
  1677. *
  1678. * Existence of this extension means the driver can accept the
  1679. * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
  1680. * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
  1681. * \c __DRIdri2ExtensionRec::createContextAttribs.
  1682. */
  1683. #define __DRI2_ROBUSTNESS "DRI_Robustness"
  1684. #define __DRI2_ROBUSTNESS_VERSION 1
  1685. typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
  1686. struct __DRIrobustnessExtensionRec {
  1687. __DRIextension base;
  1688. };
  1689. /**
  1690. * No-error context driver extension.
  1691. *
  1692. * Existence of this extension means the driver can accept the
  1693. * __DRI_CTX_FLAG_NO_ERROR flag.
  1694. */
  1695. #define __DRI2_NO_ERROR "DRI_NoError"
  1696. #define __DRI2_NO_ERROR_VERSION 1
  1697. typedef struct __DRInoErrorExtensionRec {
  1698. __DRIextension base;
  1699. } __DRInoErrorExtension;
  1700. /*
  1701. * Flush control driver extension.
  1702. *
  1703. * Existence of this extension means the driver can accept the
  1704. * \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in
  1705. * \c __DRIdri2ExtensionRec::createContextAttribs.
  1706. */
  1707. #define __DRI2_FLUSH_CONTROL "DRI_FlushControl"
  1708. #define __DRI2_FLUSH_CONTROL_VERSION 1
  1709. typedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension;
  1710. struct __DRI2flushControlExtensionRec {
  1711. __DRIextension base;
  1712. };
  1713. /**
  1714. * DRI config options extension.
  1715. *
  1716. * This extension provides the XML string containing driver options for use by
  1717. * the loader in supporting the driconf application.
  1718. *
  1719. * v2:
  1720. * - Add the getXml getter function which allows the driver more flexibility in
  1721. * how the XML is provided.
  1722. * - Deprecate the direct xml pointer. It is only provided as a fallback for
  1723. * older versions of libGL and must not be used by clients that are aware of
  1724. * the newer version. Future driver versions may set it to NULL.
  1725. */
  1726. #define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
  1727. #define __DRI_CONFIG_OPTIONS_VERSION 2
  1728. typedef struct __DRIconfigOptionsExtensionRec {
  1729. __DRIextension base;
  1730. const char *xml; /**< deprecated since v2, use getXml instead */
  1731. /**
  1732. * Get an XML string that describes available driver options for use by a
  1733. * config application.
  1734. *
  1735. * The returned string must be heap-allocated. The caller is responsible for
  1736. * freeing it.
  1737. */
  1738. char *(*getXml)(const char *driver_name);
  1739. } __DRIconfigOptionsExtension;
  1740. /**
  1741. * This extension provides a driver vtable to a set of common driver helper
  1742. * functions (driCoreExtension, driDRI2Extension) within the driver
  1743. * implementation, as opposed to having to pass them through a global
  1744. * variable.
  1745. *
  1746. * It is not intended to be public API to the actual loader, and the vtable
  1747. * layout may change at any time.
  1748. */
  1749. #define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
  1750. #define __DRI_DRIVER_VTABLE_VERSION 1
  1751. typedef struct __DRIDriverVtableExtensionRec {
  1752. __DRIextension base;
  1753. const struct __DriverAPIRec *vtable;
  1754. } __DRIDriverVtableExtension;
  1755. /**
  1756. * Query renderer driver extension
  1757. *
  1758. * This allows the window system layer (either EGL or GLX) to query aspects of
  1759. * hardware and driver support without creating a context.
  1760. */
  1761. #define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
  1762. #define __DRI2_RENDERER_QUERY_VERSION 1
  1763. #define __DRI2_RENDERER_VENDOR_ID 0x0000
  1764. #define __DRI2_RENDERER_DEVICE_ID 0x0001
  1765. #define __DRI2_RENDERER_VERSION 0x0002
  1766. #define __DRI2_RENDERER_ACCELERATED 0x0003
  1767. #define __DRI2_RENDERER_VIDEO_MEMORY 0x0004
  1768. #define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005
  1769. #define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006
  1770. #define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007
  1771. #define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008
  1772. #define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009
  1773. #define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a
  1774. #define __DRI2_RENDERER_HAS_TEXTURE_3D 0x000b
  1775. /* Whether there is an sRGB format support for every supported 32-bit UNORM
  1776. * color format.
  1777. */
  1778. #define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c
  1779. /* Bitmaks of supported/available context priorities - must match
  1780. * __EGL_CONTEXT_PRIORITY_LOW_BIT et al
  1781. */
  1782. #define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY 0x000d
  1783. #define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW (1 << 0)
  1784. #define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1)
  1785. #define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2)
  1786. #define __DRI2_RENDERER_HAS_PROTECTED_CONTENT 0x000e
  1787. #define __DRI2_RENDERER_OPENGL_ES2_CONTEXT_CLIENT_VERSION_IMG 0x7001
  1788. typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
  1789. struct __DRI2rendererQueryExtensionRec {
  1790. __DRIextension base;
  1791. int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
  1792. int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
  1793. };
  1794. /**
  1795. * Image Loader extension. Drivers use this to allocate color buffers
  1796. */
  1797. /**
  1798. * See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask.
  1799. */
  1800. enum __DRIimageBufferMask {
  1801. __DRI_IMAGE_BUFFER_BACK = (1 << 0),
  1802. __DRI_IMAGE_BUFFER_FRONT = (1 << 1),
  1803. /**
  1804. * A buffer shared between application and compositor. The buffer may be
  1805. * simultaneously accessed by each.
  1806. *
  1807. * A shared buffer is equivalent to an EGLSurface whose EGLConfig contains
  1808. * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as
  1809. * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
  1810. * EGL_SINGLE_BUFFER.
  1811. *
  1812. * If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no
  1813. * other bits. As a corollary, a __DRIdrawable that has a "shared" buffer
  1814. * has no front nor back buffer.
  1815. *
  1816. * The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only
  1817. * if:
  1818. * - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER.
  1819. * - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER.
  1820. * - The EGLConfig of the drawable EGLSurface contains
  1821. * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.
  1822. * - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER.
  1823. * Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as
  1824. * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
  1825. * EGL_SINGLE_BUFFER. (See the EGL 1.5 and
  1826. * EGL_KHR_mutable_render_buffer spec for details about "pending" vs
  1827. * "active" EGL_RENDER_BUFFER state).
  1828. *
  1829. * A shared buffer is similar to a front buffer in that all rendering to the
  1830. * buffer should appear promptly on the screen. It is different from
  1831. * a front buffer in that its behavior is independent from the
  1832. * GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the
  1833. * __DRIdrawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all
  1834. * rendering should appear promptly on the screen if GL_DRAW_BUFFER is not
  1835. * GL_NONE.
  1836. *
  1837. * The difference between a shared buffer and a front buffer is motivated
  1838. * by the constraints of Android and OpenGL ES. OpenGL ES does not support
  1839. * front-buffer rendering. Android's SurfaceFlinger protocol provides the
  1840. * EGL driver only a back buffer and no front buffer. The shared buffer
  1841. * mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though
  1842. * EGL that allows Android OpenGL ES applications to render to what is
  1843. * effectively the front buffer, a backdoor that required no change to the
  1844. * OpenGL ES API and little change to the SurfaceFlinger API.
  1845. */
  1846. __DRI_IMAGE_BUFFER_SHARED = (1 << 2),
  1847. #define DRI_IMAGE_HAS_BUFFER_PREV
  1848. __DRI_IMAGE_BUFFER_PREV = (1 << 31),
  1849. };
  1850. struct __DRIimageList {
  1851. uint32_t image_mask;
  1852. __DRIimage *back;
  1853. __DRIimage *front;
  1854. __DRIimage *prev;
  1855. };
  1856. #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
  1857. #define __DRI_IMAGE_LOADER_VERSION 5
  1858. struct __DRIimageLoaderExtensionRec {
  1859. __DRIextension base;
  1860. /**
  1861. * Allocate color buffers.
  1862. *
  1863. * \param driDrawable
  1864. * \param width Width of allocated buffers
  1865. * \param height Height of allocated buffers
  1866. * \param format one of __DRI_IMAGE_FORMAT_*
  1867. * \param stamp Address of variable to be updated when
  1868. * getBuffers must be called again
  1869. * \param loaderPrivate The loaderPrivate for driDrawable
  1870. * \param buffer_mask Set of buffers to allocate. A bitmask of
  1871. * __DRIimageBufferMask.
  1872. * \param buffers Returned buffers
  1873. */
  1874. int (*getBuffers)(__DRIdrawable *driDrawable,
  1875. unsigned int format,
  1876. uint32_t *stamp,
  1877. void *loaderPrivate,
  1878. uint32_t buffer_mask,
  1879. struct __DRIimageList *buffers);
  1880. /**
  1881. * Flush pending front-buffer rendering
  1882. *
  1883. * Any rendering that has been performed to the
  1884. * fake front will be flushed to the front
  1885. *
  1886. * \param driDrawable Drawable whose front-buffer is to be flushed
  1887. * \param loaderPrivate Loader's private data that was previously passed
  1888. * into __DRIdri2ExtensionRec::createNewDrawable
  1889. */
  1890. void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
  1891. /**
  1892. * Return a loader capability value. If the loader doesn't know the enum,
  1893. * it will return 0.
  1894. *
  1895. * \since 2
  1896. */
  1897. unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
  1898. /**
  1899. * Flush swap buffers
  1900. *
  1901. * Make sure any outstanding swap buffers have been submitted to the
  1902. * device.
  1903. *
  1904. * \param driDrawable Drawable whose swaps need to be flushed
  1905. * \param loaderPrivate Loader's private data that was previously passed
  1906. * into __DRIdri2ExtensionRec::createNewDrawable
  1907. *
  1908. * \since 3
  1909. */
  1910. void (*flushSwapBuffers)(__DRIdrawable *driDrawable, void *loaderPrivate);
  1911. /**
  1912. * Clean up any loader state associated with an image.
  1913. *
  1914. * \param loaderPrivate Loader's private data that was previously passed
  1915. * into a __DRIimageExtensionRec::createImage function
  1916. * \since 4
  1917. */
  1918. void (*destroyLoaderImageState)(void *loaderPrivate);
  1919. /**
  1920. * Get the display FD
  1921. *
  1922. * Get the FD of the display device.
  1923. *
  1924. * \param loaderPrivate The last parameter of createNewScreen or
  1925. * createNewScreen2.
  1926. * \since 5
  1927. */
  1928. int (*getDisplayFD)(void *loaderPrivate);
  1929. };
  1930. /**
  1931. * DRI extension.
  1932. */
  1933. #define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"
  1934. #define __DRI_IMAGE_DRIVER_VERSION 1
  1935. struct __DRIimageDriverExtensionRec {
  1936. __DRIextension base;
  1937. /* Common DRI functions, shared with DRI2 */
  1938. __DRIcreateNewScreen2Func createNewScreen2;
  1939. __DRIcreateNewDrawableFunc createNewDrawable;
  1940. __DRIcreateContextAttribsFunc createContextAttribs;
  1941. __DRIgetAPIMaskFunc getAPIMask;
  1942. };
  1943. /**
  1944. * Background callable loader extension.
  1945. *
  1946. * Loaders expose this extension to indicate to drivers that they are capable
  1947. * of handling callbacks from the driver's background drawing threads.
  1948. */
  1949. #define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"
  1950. #define __DRI_BACKGROUND_CALLABLE_VERSION 1
  1951. typedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension;
  1952. struct __DRIbackgroundCallableExtensionRec {
  1953. __DRIextension base;
  1954. /**
  1955. * Indicate that this thread is being used by the driver as a background
  1956. * drawing thread which may make callbacks to the loader.
  1957. *
  1958. * \param loaderPrivate is the value that was passed to to the driver when
  1959. * the context was created. This can be used by the loader to identify
  1960. * which context any callbacks are associated with.
  1961. *
  1962. * If this function is called more than once from any given thread, each
  1963. * subsequent call overrides the loaderPrivate data that was passed in the
  1964. * previous call. The driver can take advantage of this to re-use a
  1965. * background thread to perform drawing on behalf of multiple contexts.
  1966. *
  1967. * It is permissible for the driver to call this function from a
  1968. * non-background thread (i.e. a thread that has already been bound to a
  1969. * context using __DRIcoreExtensionRec::bindContext()); when this happens,
  1970. * the \c loaderPrivate pointer must be equal to the pointer that was
  1971. * passed to the driver when the currently bound context was created.
  1972. *
  1973. * This call should execute quickly enough that the driver can call it with
  1974. * impunity whenever a background thread starts performing drawing
  1975. * operations (e.g. it should just set a thread-local variable).
  1976. */
  1977. void (*setBackgroundContext)(void *loaderPrivate);
  1978. /**
  1979. * Indicate that it is multithread safe to use glthread. For GLX/EGL
  1980. * platforms using Xlib, that involves calling XInitThreads, before
  1981. * opening an X display.
  1982. *
  1983. * Note: only supported if extension version is at least 2.
  1984. *
  1985. * \param loaderPrivate is the value that was passed to to the driver when
  1986. * the context was created. This can be used by the loader to identify
  1987. * which context any callbacks are associated with.
  1988. */
  1989. GLboolean (*isThreadSafe)(void *loaderPrivate);
  1990. };
  1991. /**
  1992. * The driver portion of EGL_KHR_mutable_render_buffer.
  1993. *
  1994. * If the driver creates a __DRIconfig with
  1995. * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension.
  1996. *
  1997. * To support this extension:
  1998. *
  1999. * - The driver should create at least one __DRIconfig with
  2000. * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but
  2001. * not required.
  2002. *
  2003. * - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if
  2004. * returned by __DRIimageLoaderExtension:getBuffers().
  2005. *
  2006. * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call
  2007. * __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() in
  2008. * response to glFlush and glFinish. (This requirement is not documented
  2009. * in EGL_KHR_mutable_render_buffer, but is a de-facto requirement in the
  2010. * Android ecosystem. Android applications expect that glFlush will
  2011. * immediately display the buffer when in shared buffer mode, and Android
  2012. * drivers comply with this expectation). It :may: call
  2013. * displaySharedBuffer() more often than required.
  2014. *
  2015. * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the
  2016. * buffer is always in a format compatible for display because the
  2017. * display engine (usually SurfaceFlinger or hwcomposer) may display the
  2018. * image at any time, even concurrently with 3D rendering. For example,
  2019. * display hardware and the GL hardware may be able to access the buffer
  2020. * simultaneously. In particular, if the buffer is compressed then take
  2021. * care that SurfaceFlinger and hwcomposer can consume the compression
  2022. * format.
  2023. *
  2024. * \see __DRI_IMAGE_BUFFER_SHARED
  2025. * \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER
  2026. * \see __DRI_MUTABLE_RENDER_BUFFER_LOADER
  2027. */
  2028. #define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver"
  2029. #define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 1
  2030. typedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension;
  2031. struct __DRImutableRenderBufferDriverExtensionRec {
  2032. __DRIextension base;
  2033. };
  2034. /**
  2035. * The loader portion of EGL_KHR_mutable_render_buffer.
  2036. *
  2037. * Requires loader extension DRI_IMAGE_LOADER, through which the loader sends
  2038. * __DRI_IMAGE_BUFFER_SHARED to the driver.
  2039. *
  2040. * \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER
  2041. */
  2042. #define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader"
  2043. #define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 1
  2044. typedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension;
  2045. struct __DRImutableRenderBufferLoaderExtensionRec {
  2046. __DRIextension base;
  2047. /**
  2048. * Inform the display engine (that is, SurfaceFlinger and/or hwcomposer)
  2049. * that the __DRIdrawable has new content.
  2050. *
  2051. * The display engine may ignore this call, for example, if it continually
  2052. * refreshes and displays the buffer on every frame, as in
  2053. * EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display
  2054. * engine may refresh and display the buffer only in frames in which the
  2055. * driver calls this.
  2056. *
  2057. * If the fence_fd is not -1, then the display engine will display the
  2058. * buffer only after the fence signals.
  2059. *
  2060. * The drawable's current __DRIimageBufferMask, as returned by
  2061. * __DRIimageLoaderExtension::getBuffers(), must be
  2062. * __DRI_IMAGE_BUFFER_SHARED.
  2063. */
  2064. void (*displaySharedBuffer)(__DRIdrawable *drawable, int fence_fd,
  2065. void *loaderPrivate);
  2066. };
  2067. #endif