xref: /aosp_15_r20/external/mesa3d/src/gallium/include/mesa_interface.h (revision 6104692788411f58d303aa86923a9ff6ecaded22)
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  * Copyright © 2022 Google LLC
7  *
8  * Permission is hereby granted, free of charge, to any person obtaining a
9  * copy of this software and associated documentation files (the "Software"),
10  * to deal in the Software without restriction, including without limitation
11  * the rights to use, copy, modify, merge, publish, distribute, sublicense,
12  * and/or sell copies of the Software, and to permit persons to whom the
13  * Software is furnished to do so, subject to the following conditions:
14  *
15  * The above copyright notice and this permission notice (including the next
16  * paragraph) shall be included in all copies or substantial portions of the
17  * Software.
18  *
19  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
20  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21  * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
22  * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
23  * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
24  * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS
25  * IN THE SOFTWARE.
26  */
27 
28 #ifndef MESA_INTERFACE_H
29 #define MESA_INTERFACE_H
30 
31 
32 #include <stdbool.h>
33 #include <stdint.h>
34 
35 /**
36  * \name DRI interface structures
37  *
38  * The following structures define the interface between the GLX client
39  * side library and the DRI (direct rendering infrastructure).
40  */
41 /*@{*/
42 typedef struct __DRIdisplayRec		__DRIdisplay;
43 typedef struct __DRIscreenRec		__DRIscreen;
44 typedef struct __DRIcontextRec		__DRIcontext;
45 typedef struct __DRIdrawableRec		__DRIdrawable;
46 typedef struct __DRIconfigRec		__DRIconfig;
47 typedef struct __DRIframebufferRec	__DRIframebuffer;
48 typedef struct __DRIversionRec		__DRIversion;
49 
50 typedef struct __DRIcoreExtensionRec		__DRIcoreExtension;
51 typedef struct __DRIextensionRec		__DRIextension;
52 typedef struct __DRIswapControlExtensionRec	__DRIswapControlExtension;
53 typedef struct __DRIframeTrackingExtensionRec	__DRIframeTrackingExtension;
54 typedef struct __DRImediaStreamCounterExtensionRec	__DRImediaStreamCounterExtension;
55 typedef struct __DRItexOffsetExtensionRec	__DRItexOffsetExtension;
56 typedef struct __DRItexBufferExtensionRec	__DRItexBufferExtension;
57 typedef struct __DRIlegacyExtensionRec		__DRIlegacyExtension; /* DRI1, structures of which have been deleted from the tree */
58 typedef struct __DRIswrastExtensionRec		__DRIswrastExtension;
59 typedef struct __DRIbufferRec			__DRIbuffer;
60 typedef struct __DRIdri2ExtensionRec		__DRIdri2Extension;
61 typedef struct __DRIdri2LoaderExtensionRec	__DRIdri2LoaderExtension;
62 typedef struct __DRI2flushExtensionRec	__DRI2flushExtension;
63 typedef struct __DRI2fenceExtensionRec          __DRI2fenceExtension;
64 typedef struct __DRI2interopExtensionRec	__DRI2interopExtension;
65 typedef struct __DRI2blobExtensionRec           __DRI2blobExtension;
66 typedef struct __DRI2bufferDamageExtensionRec   __DRI2bufferDamageExtension;
67 
68 typedef struct __DRIimageLoaderExtensionRec     __DRIimageLoaderExtension;
69 typedef struct __DRIimageDriverExtensionRec     __DRIimageDriverExtension;
70 
71 /*@}*/
72 
73 
74 /**
75  * Extension struct.  Drivers 'inherit' from this struct by embedding
76  * it as the first element in the extension struct.
77  *
78  * We never break API in for a DRI extension.  If we need to change
79  * the way things work in a non-backwards compatible manner, we
80  * introduce a new extension.  During a transition period, we can
81  * leave both the old and the new extension in the driver, which
82  * allows us to move to the new interface without having to update the
83  * loader(s) in lock step.
84  *
85  * However, we can add entry points to an extension over time as long
86  * as we don't break the old ones.  As we add entry points to an
87  * extension, we increase the version number.  The corresponding
88  * #define can be used to guard code that accesses the new entry
89  * points at compile time and the version field in the extension
90  * struct can be used at run-time to determine how to use the
91  * extension.
92  */
93 struct __DRIextensionRec {
94     const char *name;
95     int version;
96 };
97 
98 /**
99  * The first set of extension are the screen extensions, returned by
100  * __DRIcore::getExtensions().  This entry point will return a list of
101  * extensions and the loader can use the ones it knows about by
102  * casting them to more specific extensions and advertising any GLX
103  * extensions the DRI extensions enables.
104  */
105 
106 /**
107  * Used by drivers to indicate support for setting the read drawable.
108  */
109 #define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
110 #define __DRI_READ_DRAWABLE_VERSION 1
111 
112 /**
113  * Used by drivers that implement the GLX_SGI_swap_control or
114  * GLX_MESA_swap_control extension.
115  *
116  * Used by the X server.
117  */
118 #define __DRI_SWAP_CONTROL "DRI_SwapControl"
119 #define __DRI_SWAP_CONTROL_VERSION 1
120 struct __DRIswapControlExtensionRec {
121     __DRIextension base;
122     void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
123     unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
124 };
125 
126 /**
127  * Used by drivers that implement the GLX_SGI_video_sync extension.
128  *
129  * Not used by the X server.
130  */
131 #define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
132 #define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
133 struct __DRImediaStreamCounterExtensionRec {
134     __DRIextension base;
135 
136     /**
137      * Wait for the MSC to equal target_msc, or, if that has already passed,
138      * the next time (MSC % divisor) is equal to remainder.  If divisor is
139      * zero, the function will return as soon as MSC is greater than or equal
140      * to target_msc.
141      */
142     int (*waitForMSC)(__DRIdrawable *drawable,
143 		      int64_t target_msc, int64_t divisor, int64_t remainder,
144 		      int64_t * msc, int64_t * sbc);
145 
146     /**
147      * Get the number of vertical refreshes since some point in time before
148      * this function was first called (i.e., system start up).
149      */
150     int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
151 			  int64_t *msc);
152 };
153 
154 /* Valid values for format in the setTexBuffer2 function below.  These
155  * values match the GLX tokens for compatibility reasons, but we
156  * define them here since the DRI interface can't depend on GLX. */
157 #define __DRI_TEXTURE_FORMAT_NONE        0x20D8
158 #define __DRI_TEXTURE_FORMAT_RGB         0x20D9
159 #define __DRI_TEXTURE_FORMAT_RGBA        0x20DA
160 
161 #define __DRI_TEX_BUFFER "DRI_TexBuffer"
162 #define __DRI_TEX_BUFFER_VERSION 3
163 struct __DRItexBufferExtensionRec {
164     __DRIextension base;
165 
166     /**
167      * Method to override base texture image with the contents of a
168      * __DRIdrawable, including the required texture format attribute.
169      *
170      * For GLX_EXT_texture_from_pixmap with AIGLX.  Used by the X server since
171      * 2011.
172      *
173      * \since 2
174      */
175     void (*setTexBuffer2)(__DRIcontext *pDRICtx,
176 			  int target,
177 			  int format,
178 			  __DRIdrawable *pDraw);
179 };
180 
181 /**
182  * Used by drivers that implement DRI2.  Version 3 is used by the X server.
183  */
184 #define __DRI2_FLUSH "DRI2_Flush"
185 #define __DRI2_FLUSH_VERSION 4
186 
187 #define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
188 #define __DRI2_FLUSH_CONTEXT  (1 << 1) /* glFlush should be called */
189 #define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2)
190 
191 enum __DRI2throttleReason {
192    __DRI2_THROTTLE_SWAPBUFFER,
193    __DRI2_THROTTLE_COPYSUBBUFFER,
194    __DRI2_THROTTLE_FLUSHFRONT,
195    __DRI2_NOTHROTTLE_SWAPBUFFER,
196 };
197 
198 struct __DRI2flushExtensionRec {
199     __DRIextension base;
200     void (*flush)(__DRIdrawable *drawable);
201 
202     /**
203      * Ask the driver to call getBuffers/getBuffersWithFormat before
204      * it starts rendering again.
205      *
206      * \param drawable the drawable to invalidate
207      *
208      * \since 3
209      */
210     void (*invalidate)(__DRIdrawable *drawable);
211 
212     /**
213      * This function reduces the number of flushes in the driver by combining
214      * several operations into one call.
215      *
216      * It can:
217      * - throttle
218      * - flush a drawable
219      * - flush a context
220      *
221      * \param context           the context
222      * \param drawable          the drawable to flush
223      * \param flags             a combination of _DRI2_FLUSH_xxx flags
224      * \param throttle_reason   the reason for throttling, 0 = no throttling
225      *
226      * \since 4
227      */
228     void (*flush_with_flags)(__DRIcontext *ctx,
229                              __DRIdrawable *drawable,
230                              unsigned flags,
231                              enum __DRI2throttleReason throttle_reason);
232 };
233 
234 /**
235  * Extension for EGL_ANDROID_blob_cache
236  * *
237  * Not used by the X server.
238  */
239 
240 #define __DRI2_BLOB "DRI2_Blob"
241 #define __DRI2_BLOB_VERSION 1
242 
243 typedef void
244 (*__DRIblobCacheSet) (const void *key, signed long keySize,
245                       const void *value, signed long valueSize);
246 
247 typedef signed long
248 (*__DRIblobCacheGet) (const void *key, signed long keySize,
249                       void *value, signed long valueSize);
250 
251 struct __DRI2blobExtensionRec {
252    __DRIextension base;
253 
254    /**
255     * Set cache functions for setting and getting cache entries.
256     */
257    void (*set_cache_funcs) (__DRIscreen *screen,
258                             __DRIblobCacheSet set, __DRIblobCacheGet get);
259 };
260 
261 /**
262  * Extension for fences / synchronization objects.
263  * *
264  * Not used by the X server.
265  */
266 
267 #define __DRI2_FENCE "DRI2_Fence"
268 #define __DRI2_FENCE_VERSION 2
269 
270 #define __DRI2_FENCE_TIMEOUT_INFINITE     0xffffffffffffffffull
271 
272 #define __DRI2_FENCE_FLAG_FLUSH_COMMANDS  (1 << 0)
273 
274 /**
275  * \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities
276  */
277 /*@{*/
278 #define __DRI_FENCE_CAP_NATIVE_FD 1
279 /*@}*/
280 
281 struct __DRI2fenceExtensionRec {
282    __DRIextension base;
283 
284    /**
285     * Create and insert a fence into the command stream of the context.
286     */
287    void *(*create_fence)(__DRIcontext *ctx);
288 
289    /**
290     * Get a fence associated with the OpenCL event object.
291     * This can be NULL, meaning that OpenCL interoperability is not supported.
292     */
293    void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event);
294 
295    /**
296     * Destroy a fence.
297     */
298    void (*destroy_fence)(__DRIscreen *screen, void *fence);
299 
300    /**
301     * This function waits and doesn't return until the fence is signalled
302     * or the timeout expires. It returns true if the fence has been signaled.
303     *
304     * \param ctx     the context where commands are flushed
305     * \param fence   the fence
306     * \param flags   a combination of __DRI2_FENCE_FLAG_xxx flags
307     * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE
308     */
309    unsigned char (*client_wait_sync)(__DRIcontext *ctx, void *fence,
310                                      unsigned flags, uint64_t timeout);
311 
312    /**
313     * This function enqueues a wait command into the command stream of
314     * the context and then returns. When the execution reaches the wait
315     * command, no further execution will be done in the context until
316     * the fence is signaled. This is a no-op if the device doesn't support
317     * parallel execution of contexts.
318     *
319     * \param ctx     the context where the waiting is done
320     * \param fence   the fence
321     * \param flags   a combination of __DRI2_FENCE_FLAG_xxx flags that make
322     *                sense with this function (right now there are none)
323     */
324    void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags);
325 
326    /**
327     * Query for general capabilities of the driver that concern fences.
328     * Returns a bitmask of __DRI_FENCE_CAP_x
329     *
330     * \since 2
331     */
332    unsigned (*get_capabilities)(__DRIscreen *screen);
333 
334    /**
335     * Create an fd (file descriptor) associated fence.  If the fence fd
336     * is -1, this behaves similarly to create_fence() except that when
337     * rendering is flushed the driver creates a fence fd.  Otherwise,
338     * the driver wraps an existing fence fd.
339     *
340     * This is used to implement the EGL_ANDROID_native_fence_sync extension.
341     *
342     * \since 2
343     *
344     * \param ctx     the context associated with the fence
345     * \param fd      the fence fd or -1
346     */
347    void *(*create_fence_fd)(__DRIcontext *ctx, int fd);
348 
349    /**
350     * For fences created with create_fence_fd(), after rendering is flushed,
351     * this retrieves the native fence fd.  Caller takes ownership of the
352     * fd and will close() it when it is no longer needed.
353     *
354     * \since 2
355     *
356     * \param screen  the screen associated with the fence
357     * \param fence   the fence
358     */
359    int (*get_fence_fd)(__DRIscreen *screen, void *fence);
360 };
361 
362 
363 /**
364  * Extension for API interop.
365  * See GL/mesa_glinterop.h.
366  * *
367  * Not used by the X server.
368  */
369 
370 #define __DRI2_INTEROP "DRI2_Interop"
371 #define __DRI2_INTEROP_VERSION 2
372 
373 struct mesa_glinterop_device_info;
374 struct mesa_glinterop_export_in;
375 struct mesa_glinterop_export_out;
376 struct mesa_glinterop_flush_out;
377 typedef struct __GLsync *GLsync;
378 
379 struct __DRI2interopExtensionRec {
380    __DRIextension base;
381 
382    /** Same as MesaGLInterop*QueryDeviceInfo. */
383    int (*query_device_info)(__DRIcontext *ctx,
384                             struct mesa_glinterop_device_info *out);
385 
386    /** Same as MesaGLInterop*ExportObject. */
387    int (*export_object)(__DRIcontext *ctx,
388                         struct mesa_glinterop_export_in *in,
389                         struct mesa_glinterop_export_out *out);
390 
391    /**
392     * Same as MesaGLInterop*FlushObjects.
393     *
394     * \since 2
395     */
396    int (*flush_objects)(__DRIcontext *ctx,
397                         unsigned count, struct mesa_glinterop_export_in *objects,
398                         struct mesa_glinterop_flush_out *out);
399 };
400 
401 
402 /**
403  * Extension for limiting window system back buffer rendering to user-defined
404  * scissor region.
405  *
406  * Not used by the X server.
407  */
408 
409 #define __DRI2_BUFFER_DAMAGE "DRI2_BufferDamage"
410 #define __DRI2_BUFFER_DAMAGE_VERSION 1
411 
412 struct __DRI2bufferDamageExtensionRec {
413    __DRIextension base;
414 
415    /**
416     * Provides an array of rectangles representing an overriding scissor region
417     * for rendering operations performed to the specified drawable. These
418     * rectangles do not replace client API scissor regions or draw
419     * co-ordinates, but instead inform the driver of the overall bounds of all
420     * operations which will be issued before the next flush.
421     *
422     * Any rendering operations writing pixels outside this region to the
423     * drawable will have an undefined effect on the entire drawable.
424     *
425     * This entrypoint may only be called after the drawable has either been
426     * newly created or flushed, and before any rendering operations which write
427     * pixels to the drawable. Calling this entrypoint at any other time will
428     * have an undefined effect on the entire drawable.
429     *
430     * Calling this entrypoint with @nrects 0 and @rects NULL will reset the
431     * region to the buffer's full size. This entrypoint may be called once to
432     * reset the region, followed by a second call with a populated region,
433     * before a rendering call is made.
434     *
435     * Used to implement EGL_KHR_partial_update.
436     *
437     * \param drawable affected drawable
438     * \param nrects   number of rectangles provided
439     * \param rects    the array of rectangles, lower-left origin
440     */
441    void (*set_damage_region)(__DRIdrawable *drawable, unsigned int nrects,
442                              int *rects);
443 };
444 
445 /*@}*/
446 
447 /**
448  * The following extensions describe loader features that the DRI
449  * driver can make use of.  Some of these are mandatory, such as the
450  * getDrawableInfo extension for DRI and the DRI Loader extensions for
451  * DRI2, while others are optional, and if present allow the driver to
452  * expose certain features.  The loader pass in a NULL terminated
453  * array of these extensions to the driver in the createNewScreen
454  * constructor.
455  */
456 
457 typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
458 typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
459 typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
460 typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
461 typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
462 
463 /**
464  * Callback to get system time for media stream counter extensions.
465  *
466  * Not used by the X server.
467  */
468 #define __DRI_SYSTEM_TIME "DRI_SystemTime"
469 #define __DRI_SYSTEM_TIME_VERSION 1
470 struct __DRIsystemTimeExtensionRec {
471     __DRIextension base;
472 
473     /**
474      * Get the 64-bit unadjusted system time (UST).
475      */
476     int (*getUST)(int64_t * ust);
477 
478     /**
479      * Get the media stream counter (MSC) rate.
480      *
481      * Matching the definition in GLX_OML_sync_control, this function returns
482      * the rate of the "media stream counter".  In practical terms, this is
483      * the frame refresh rate of the display.
484      */
485     unsigned char (*getMSCRate)(__DRIdrawable *draw,
486 			    int32_t * numerator, int32_t * denominator,
487 			    void *loaderPrivate);
488 };
489 
490 #define __DRI_SWRAST_IMAGE_OP_DRAW	1
491 #define __DRI_SWRAST_IMAGE_OP_CLEAR	2
492 #define __DRI_SWRAST_IMAGE_OP_SWAP	3
493 
494 /**
495  * SWRast Loader extension.
496  *
497  * Version 1 is advertised by the X server.
498  */
499 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
500 #define __DRI_SWRAST_LOADER_VERSION 6
501 struct __DRIswrastLoaderExtensionRec {
502     __DRIextension base;
503 
504     /*
505      * Drawable position and size
506      */
507     void (*getDrawableInfo)(__DRIdrawable *drawable,
508 			    int *x, int *y, int *width, int *height,
509 			    void *loaderPrivate);
510 
511     /**
512      * Put image to drawable
513      */
514     void (*putImage)(__DRIdrawable *drawable, int op,
515 		     int x, int y, int width, int height,
516 		     char *data, void *loaderPrivate);
517 
518     /**
519      * Get image from readable
520      */
521     void (*getImage)(__DRIdrawable *readable,
522 		     int x, int y, int width, int height,
523 		     char *data, void *loaderPrivate);
524 
525     /**
526      * Put image to drawable
527      *
528      * \since 2
529      */
530     void (*putImage2)(__DRIdrawable *drawable, int op,
531                       int x, int y, int width, int height, int stride,
532                       char *data, void *loaderPrivate);
533 
534    /**
535      * Put image to drawable
536      *
537      * \since 3
538      */
539    void (*getImage2)(__DRIdrawable *readable,
540 		     int x, int y, int width, int height, int stride,
541 		     char *data, void *loaderPrivate);
542 
543     /**
544      * Put shm image to drawable
545      *
546      * \since 4
547      */
548     void (*putImageShm)(__DRIdrawable *drawable, int op,
549                         int x, int y, int width, int height, int stride,
550                         int shmid, char *shmaddr, unsigned offset,
551                         void *loaderPrivate);
552     /**
553      * Get shm image from readable
554      *
555      * \since 4
556      */
557     void (*getImageShm)(__DRIdrawable *readable,
558                         int x, int y, int width, int height,
559                         int shmid, void *loaderPrivate);
560 
561    /**
562      * Put shm image to drawable (v2)
563      *
564      * The original version fixes srcx/y to 0, and expected
565      * the offset to be adjusted. This version allows src x,y
566      * to not be included in the offset. This is needed to
567      * avoid certain overflow checks in the X server, that
568      * result in lost rendering.
569      *
570      * \since 5
571      */
572     void (*putImageShm2)(__DRIdrawable *drawable, int op,
573                          int x, int y,
574                          int width, int height, int stride,
575                          int shmid, char *shmaddr, unsigned offset,
576                          void *loaderPrivate);
577 
578     /**
579      * get shm image to drawable (v2)
580      *
581      * There are some cases where GLX can't use SHM, but DRI
582      * still tries, we need to get a return type for when to
583      * fallback to the non-shm path.
584      *
585      * \since 6
586      */
587     unsigned char (*getImageShm2)(__DRIdrawable *readable,
588                                   int x, int y, int width, int height,
589                                   int shmid, void *loaderPrivate);
590 };
591 
592 /**
593  * Invalidate loader extension.  The presence of this extension
594  * indicates to the DRI driver that the loader will call invalidate in
595  * the __DRI2_FLUSH extension, whenever the needs to query for new
596  * buffers.  This means that the DRI driver can drop the polling in
597  * glViewport().
598  *
599  * The extension doesn't provide any functionality, it's only use to
600  * indicate to the driver that it can use the new semantics.  A DRI
601  * driver can use this to switch between the different semantics or
602  * just refuse to initialize if this extension isn't present.
603  *
604  * Advertised by the X server.
605  */
606 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
607 #define __DRI_USE_INVALIDATE_VERSION 1
608 
609 typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
610 struct __DRIuseInvalidateExtensionRec {
611    __DRIextension base;
612 };
613 
614 /**
615  * Tokens for __DRIconfig attribs.  A number of attributes defined by
616  * GLX or EGL standards are not in the table, as they must be provided
617  * by the loader.  For example, FBConfig ID or visual ID, drawable type.
618  */
619 
620 #define __DRI_ATTRIB_BUFFER_SIZE		 1
621 #define __DRI_ATTRIB_LEVEL			 2
622 #define __DRI_ATTRIB_RED_SIZE			 3
623 #define __DRI_ATTRIB_GREEN_SIZE			 4
624 #define __DRI_ATTRIB_BLUE_SIZE			 5
625 #define __DRI_ATTRIB_LUMINANCE_SIZE		 6
626 #define __DRI_ATTRIB_ALPHA_SIZE			 7
627 #define __DRI_ATTRIB_ALPHA_MASK_SIZE		 8
628 #define __DRI_ATTRIB_DEPTH_SIZE			 9
629 #define __DRI_ATTRIB_STENCIL_SIZE		10
630 #define __DRI_ATTRIB_ACCUM_RED_SIZE		11
631 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE		12
632 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE		13
633 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE		14
634 #define __DRI_ATTRIB_SAMPLE_BUFFERS		15
635 #define __DRI_ATTRIB_SAMPLES			16
636 #define __DRI_ATTRIB_RENDER_TYPE		17
637 #define __DRI_ATTRIB_CONFIG_CAVEAT		18
638 #define __DRI_ATTRIB_CONFORMANT			19
639 #define __DRI_ATTRIB_DOUBLE_BUFFER		20
640 #define __DRI_ATTRIB_STEREO			21
641 #define __DRI_ATTRIB_AUX_BUFFERS		22
642 #define __DRI_ATTRIB_TRANSPARENT_TYPE		23
643 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE	24
644 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE	25
645 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE	26
646 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE	27
647 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE	28
648 #define __DRI_ATTRIB_FLOAT_MODE			29
649 #define __DRI_ATTRIB_RED_MASK			30
650 #define __DRI_ATTRIB_GREEN_MASK			31
651 #define __DRI_ATTRIB_BLUE_MASK			32
652 #define __DRI_ATTRIB_ALPHA_MASK			33
653 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH		34
654 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT		35
655 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS		36
656 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH	37
657 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT	38
658 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP	39
659 #define __DRI_ATTRIB_SWAP_METHOD		40 // Parsed by the X server when our visuals return it as an attrib.
660 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL		41
661 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL		42
662 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB	43
663 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA	44
664 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE	45
665 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS	46
666 #define __DRI_ATTRIB_YINVERTED			47
667 #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE	48
668 #define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER	49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */
669 #define __DRI_ATTRIB_RED_SHIFT			50
670 #define __DRI_ATTRIB_GREEN_SHIFT		51
671 #define __DRI_ATTRIB_BLUE_SHIFT			52
672 #define __DRI_ATTRIB_ALPHA_SHIFT		53
673 #define __DRI_ATTRIB_MAX			54
674 
675 /* __DRI_ATTRIB_RENDER_TYPE */
676 #define __DRI_ATTRIB_RGBA_BIT			0x01
677 #define __DRI_ATTRIB_COLOR_INDEX_BIT		0x02
678 #define __DRI_ATTRIB_LUMINANCE_BIT		0x04
679 #define __DRI_ATTRIB_FLOAT_BIT			0x08
680 #define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT		0x10
681 
682 /* __DRI_ATTRIB_CONFIG_CAVEAT */
683 #define __DRI_ATTRIB_SLOW_BIT			0x01
684 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG	0x02
685 
686 /* __DRI_ATTRIB_TRANSPARENT_TYPE */
687 #define __DRI_ATTRIB_TRANSPARENT_RGB		0x00
688 #define __DRI_ATTRIB_TRANSPARENT_INDEX		0x01
689 
690 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS	 */
691 #define __DRI_ATTRIB_TEXTURE_1D_BIT		0x01
692 #define __DRI_ATTRIB_TEXTURE_2D_BIT		0x02
693 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT	0x04
694 
695 /* __DRI_ATTRIB_SWAP_METHOD */
696 /* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define
697  * the same tokens as GLX. This is because old and current X servers will
698  * transmit the driconf value grabbed from the AIGLX driver untranslated as
699  * the GLX fbconfig value. These defines are kept for X Server suorce compatibility,
700  * since Mesa no longer exposes GLX_OML_swap_method.
701  */
702 #define __DRI_ATTRIB_SWAP_NONE                  0x0000
703 #define __DRI_ATTRIB_SWAP_EXCHANGE              0x8061
704 #define __DRI_ATTRIB_SWAP_COPY                  0x8062
705 #define __DRI_ATTRIB_SWAP_UNDEFINED             0x8063
706 
707 /**
708  * This extension defines the core DRI functionality.  It was introduced when
709  * DRI2 and AIGLX were added.
710  *
711  * Version >= 2 indicates that getConfigAttrib with __DRI_ATTRIB_SWAP_METHOD
712  * returns a reliable value.  The X server requires v1 and uses v2.
713  */
714 #define __DRI_CORE "DRI_Core"
715 #define __DRI_CORE_VERSION 3
716 
717 struct __DRIcoreExtensionRec {
718     __DRIextension base;
719 
720     /* Not used by the X server. */
721     __DRIscreen *(*createNewScreen)(int screen, int fd,
722 				    unsigned int sarea_handle,
723 				    const __DRIextension **extensions,
724 				    const __DRIconfig ***driverConfigs,
725 				    void *loaderPrivate);
726 
727     void (*destroyScreen)(__DRIscreen *screen);
728 
729     const __DRIextension **(*getExtensions)(__DRIscreen *screen);
730 
731     /* Not used by the X server. */
732     int (*getConfigAttrib)(const __DRIconfig *config,
733 			   unsigned int attrib,
734 			   unsigned int *value);
735 
736     /* Not used by the X server. */
737     int (*indexConfigAttrib)(const __DRIconfig *config, int index,
738 			     unsigned int *attrib, unsigned int *value);
739 
740     /* Not used by the X server. */
741     __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
742 					const __DRIconfig *config,
743 					unsigned int drawable_id,
744 					unsigned int head,
745 					void *loaderPrivate);
746 
747     /* Used by the X server */
748     void (*destroyDrawable)(__DRIdrawable *drawable);
749 
750     /* Used by the X server in swrast mode. */
751     void (*swapBuffers)(__DRIdrawable *drawable);
752 
753     /* Used by the X server in swrast mode. */
754     __DRIcontext *(*createNewContext)(__DRIscreen *screen,
755 				      const __DRIconfig *config,
756 				      __DRIcontext *shared,
757 				      void *loaderPrivate);
758 
759     /* Used by the X server. */
760     int (*copyContext)(__DRIcontext *dest,
761 		       __DRIcontext *src,
762 		       unsigned long mask);
763 
764     /* Used by the X server. */
765     void (*destroyContext)(__DRIcontext *context);
766 
767     /* Used by the X server. */
768     int (*bindContext)(__DRIcontext *ctx,
769 		       __DRIdrawable *pdraw,
770 		       __DRIdrawable *pread);
771 
772     /* Used by the X server. */
773     int (*unbindContext)(__DRIcontext *ctx);
774 
775     void (*swapBuffersWithDamage)(__DRIdrawable *drawable, int nrects, const int *rects);
776 };
777 
778 /**
779  * Stored version of some component (i.e., server-side DRI module, kernel-side
780  * DRM, etc.).
781  *
782  * \todo
783  * There are several data structures that explicitly store a major version,
784  * minor version, and patch level.  These structures should be modified to
785  * have a \c __DRIversionRec instead.
786  *
787  * Not used by the X server since DRI1 was deleted.
788  */
789 struct __DRIversionRec {
790     int    major;        /**< Major version number. */
791     int    minor;        /**< Minor version number. */
792     int    patch;        /**< Patch-level. */
793 };
794 
795 /**
796  * Framebuffer information record.  Used by libGL to communicate information
797  * about the framebuffer to the driver's \c __driCreateNewScreen function.
798  *
799  * In XFree86, most of this information is derrived from data returned by
800  * calling \c XF86DRIGetDeviceInfo.
801  *
802  * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
803  *     __driUtilCreateNewScreen CallCreateNewScreen
804  *
805  * \bug This structure could be better named.
806  *
807  * Not used by the X server since DRI1 was deleted.
808  */
809 struct __DRIframebufferRec {
810     unsigned char *base;    /**< Framebuffer base address in the CPU's
811 			     * address space.  This value is calculated by
812 			     * calling \c drmMap on the framebuffer handle
813 			     * returned by \c XF86DRIGetDeviceInfo (or a
814 			     * similar function).
815 			     */
816     int size;               /**< Framebuffer size, in bytes. */
817     int stride;             /**< Number of bytes from one line to the next. */
818     int width;              /**< Pixel width of the framebuffer. */
819     int height;             /**< Pixel height of the framebuffer. */
820     int dev_priv_size;      /**< Size of the driver's dev-priv structure. */
821     void *dev_priv;         /**< Pointer to the driver's dev-priv structure. */
822 };
823 
824 
825 /**
826  * This extension provides alternative screen, drawable and context constructors
827  * for swrast DRI functionality.  This is used in conjunction with the core
828  * extension.  Version 1 is required by the X server, and version 3 is used.
829  */
830 #define __DRI_SWRAST "DRI_SWRast"
831 #define __DRI_SWRAST_VERSION 6
832 
833 struct __DRIswrastExtensionRec {
834     __DRIextension base;
835 
836     __DRIscreen *(*createNewScreen)(int screen,
837 				    const __DRIextension **extensions,
838 				    const __DRIconfig ***driver_configs,
839 				    void *loaderPrivate);
840 
841     __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
842 					const __DRIconfig *config,
843 					void *loaderPrivate);
844 
845    /* Since version 2 */
846    __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
847                                            int api,
848                                            const __DRIconfig *config,
849                                            __DRIcontext *shared,
850                                            void *data);
851 
852    /**
853     * Create a context for a particular API with a set of attributes
854     *
855     * \since version 3
856     *
857     * \sa __DRIdri2ExtensionRec::createContextAttribs
858     */
859    __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
860 					 int api,
861 					 const __DRIconfig *config,
862 					 __DRIcontext *shared,
863 					 unsigned num_attribs,
864 					 const uint32_t *attribs,
865 					 unsigned *error,
866 					 void *loaderPrivate);
867 
868    /**
869     * createNewScreen() with the driver extensions passed in.
870     *
871     * \since version 4
872     */
873    __DRIscreen *(*createNewScreen2)(int screen,
874                                     const __DRIextension **loader_extensions,
875                                     const __DRIextension **driver_extensions,
876                                     const __DRIconfig ***driver_configs,
877                                     void *loaderPrivate);
878    /**
879     * \since version 5
880    */
881    int (*queryBufferAge)(__DRIdrawable *drawable);
882 
883    /**
884     * createNewScreen() with the driver extensions passed in and implicit load flag.
885     *
886     * \since version 6
887     */
888    __DRIscreen *(*createNewScreen3)(int screen,
889                                     const __DRIextension **loader_extensions,
890                                     const __DRIextension **driver_extensions,
891                                     const __DRIconfig ***driver_configs,
892                                     bool implicit,
893                                     void *loaderPrivate);
894 
895 };
896 
897 /** Common DRI function definitions, shared among DRI2 and Image extensions
898  */
899 
900 typedef __DRIscreen *
901 (*__DRIcreateNewScreen2Func)(int screen, int fd,
902                              const __DRIextension **extensions,
903                              const __DRIextension **driver_extensions,
904                              const __DRIconfig ***driver_configs,
905                              void *loaderPrivate);
906 typedef __DRIscreen *
907 (*__DRIcreateNewScreen3Func)(int screen, int fd,
908                              const __DRIextension **extensions,
909                              const __DRIextension **driver_extensions,
910                              const __DRIconfig ***driver_configs,
911                              bool implicit,
912                              void *loaderPrivate);
913 
914 typedef __DRIdrawable *
915 (*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
916                               const __DRIconfig *config,
917                               void *loaderPrivate);
918 
919 typedef __DRIcontext *
920 (*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
921                                  int api,
922                                  const __DRIconfig *config,
923                                  __DRIcontext *shared,
924                                  unsigned num_attribs,
925                                  const uint32_t *attribs,
926                                  unsigned *error,
927                                  void *loaderPrivate);
928 
929 typedef unsigned int
930 (*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
931 
932 /**
933  * DRI2 Loader extension.
934  */
935 #define __DRI_BUFFER_FRONT_LEFT		0
936 #define __DRI_BUFFER_BACK_LEFT		1
937 #define __DRI_BUFFER_FRONT_RIGHT	2
938 #define __DRI_BUFFER_BACK_RIGHT		3
939 #define __DRI_BUFFER_DEPTH		4
940 #define __DRI_BUFFER_STENCIL		5
941 #define __DRI_BUFFER_ACCUM		6
942 #define __DRI_BUFFER_FAKE_FRONT_LEFT	7
943 #define __DRI_BUFFER_FAKE_FRONT_RIGHT	8
944 #define __DRI_BUFFER_DEPTH_STENCIL	9  /**< Only available with DRI2 1.1 */
945 #define __DRI_BUFFER_HIZ		10
946 
947 /* Inofficial and for internal use. Increase when adding a new buffer token. */
948 #define __DRI_BUFFER_COUNT		11
949 
950 /* Used by the X server. */
951 struct __DRIbufferRec {
952     unsigned int attachment;
953     unsigned int name;
954     unsigned int pitch;
955     unsigned int cpp;
956     unsigned int flags;
957 };
958 
959 /* The X server implements up to version 3 of the DRI2 loader. */
960 #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
961 #define __DRI_DRI2_LOADER_VERSION 5
962 
963 enum dri_loader_cap {
964    /* Whether the loader handles RGBA channel ordering correctly. If not,
965     * only BGRA ordering can be exposed.
966     */
967    DRI_LOADER_CAP_RGBA_ORDERING,
968    DRI_LOADER_CAP_FP16,
969 };
970 
971 struct __DRIdri2LoaderExtensionRec {
972     __DRIextension base;
973 
974     __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
975 			       int *width, int *height,
976 			       unsigned int *attachments, int count,
977 			       int *out_count, void *loaderPrivate);
978 
979     /**
980      * Flush pending front-buffer rendering
981      *
982      * Any rendering that has been performed to the
983      * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
984      * \c __DRI_BUFFER_FRONT_LEFT.
985      *
986      * \param driDrawable    Drawable whose front-buffer is to be flushed
987      * \param loaderPrivate  Loader's private data that was previously passed
988      *                       into __DRIdri2ExtensionRec::createNewDrawable
989      *
990      * \since 2
991      */
992     void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
993 
994 
995     /**
996      * Get list of buffers from the server
997      *
998      * Gets a list of buffer for the specified set of attachments.  Unlike
999      * \c ::getBuffers, this function takes a list of attachments paired with
1000      * opaque \c unsigned \c int value describing the format of the buffer.
1001      * It is the responsibility of the caller to know what the service that
1002      * allocates the buffers will expect to receive for the format.
1003      *
1004      * \param driDrawable    Drawable whose buffers are being queried.
1005      * \param width          Output where the width of the buffers is stored.
1006      * \param height         Output where the height of the buffers is stored.
1007      * \param attachments    List of pairs of attachment ID and opaque format
1008      *                       requested for the drawable.
1009      * \param count          Number of attachment / format pairs stored in
1010      *                       \c attachments.
1011      * \param loaderPrivate  Loader's private data that was previously passed
1012      *                       into __DRIdri2ExtensionRec::createNewDrawable.
1013      *
1014      * \since 3
1015      */
1016     __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
1017 					 int *width, int *height,
1018 					 unsigned int *attachments, int count,
1019 					 int *out_count, void *loaderPrivate);
1020 
1021     /**
1022      * Return a loader capability value. If the loader doesn't know the enum,
1023      * it will return 0.
1024      *
1025      * \param loaderPrivate The last parameter of createNewScreen or
1026      *                      createNewScreen2.
1027      * \param cap           See the enum.
1028      *
1029      * \since 4
1030      */
1031     unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
1032 
1033     /**
1034      * Clean up any loader state associated with an image.
1035      *
1036      * \param loaderPrivate  Loader's private data that was previously passed
1037      *                       into a __DRIimageExtensionRec::createImage function
1038      * \since 5
1039      */
1040     void (*destroyLoaderImageState)(void *loaderPrivate);
1041 };
1042 
1043 /**
1044  * This extension provides alternative screen, drawable and context
1045  * constructors for DRI2.  The X server uses up to version 4.
1046  */
1047 #define __DRI_DRI2 "DRI_DRI2"
1048 #define __DRI_DRI2_VERSION 5
1049 
1050 #define __DRI_API_OPENGL	0	/**< OpenGL compatibility profile */
1051 #define __DRI_API_GLES		1	/**< OpenGL ES 1.x */
1052 #define __DRI_API_GLES2		2	/**< OpenGL ES 2.x */
1053 #define __DRI_API_OPENGL_CORE	3	/**< OpenGL 3.2+ core profile */
1054 #define __DRI_API_GLES3		4	/**< OpenGL ES 3.x */
1055 
1056 #define __DRI_CTX_ATTRIB_MAJOR_VERSION		0
1057 #define __DRI_CTX_ATTRIB_MINOR_VERSION		1
1058 
1059 /* These must alias the GLX/EGL values. */
1060 #define __DRI_CTX_ATTRIB_FLAGS			2
1061 #define __DRI_CTX_FLAG_DEBUG			0x00000001
1062 #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE	0x00000002
1063 #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS	0x00000004
1064 #define __DRI_CTX_FLAG_NO_ERROR			0x00000008 /* Deprecated, do not use */
1065 /* Not yet implemented but placed here to reserve the alias with GLX */
1066 #define __DRI_CTX_FLAG_RESET_ISOLATION          0x00000008
1067 
1068 #define __DRI_CTX_ATTRIB_RESET_STRATEGY		3
1069 #define __DRI_CTX_RESET_NO_NOTIFICATION		0
1070 #define __DRI_CTX_RESET_LOSE_CONTEXT		1
1071 
1072 /**
1073  * \name Context priority levels.
1074  */
1075 #define __DRI_CTX_ATTRIB_PRIORITY		4
1076 #define __DRI_CTX_PRIORITY_LOW			0
1077 #define __DRI_CTX_PRIORITY_MEDIUM		1
1078 #define __DRI_CTX_PRIORITY_HIGH			2
1079 
1080 #define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR	5
1081 #define __DRI_CTX_RELEASE_BEHAVIOR_NONE         0
1082 #define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH        1
1083 
1084 #define __DRI_CTX_ATTRIB_NO_ERROR               6
1085 
1086 /**
1087  * \requires __DRI2_RENDER_HAS_PROTECTED_CONTEXT.
1088  *
1089  */
1090 #define __DRI_CTX_ATTRIB_PROTECTED              7
1091 
1092 
1093 #define __DRI_CTX_NUM_ATTRIBS                   8
1094 
1095 /**
1096  * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
1097  */
1098 /*@{*/
1099 /** Success! */
1100 #define __DRI_CTX_ERROR_SUCCESS			0
1101 
1102 /** Memory allocation failure */
1103 #define __DRI_CTX_ERROR_NO_MEMORY		1
1104 
1105 /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
1106 #define __DRI_CTX_ERROR_BAD_API			2
1107 
1108 /** Client requested an API version that the driver can't do. */
1109 #define __DRI_CTX_ERROR_BAD_VERSION		3
1110 
1111 /** Client requested a flag or combination of flags the driver can't do. */
1112 #define __DRI_CTX_ERROR_BAD_FLAG		4
1113 
1114 /** Client requested an attribute the driver doesn't understand. */
1115 #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE	5
1116 
1117 /** Client requested a flag the driver doesn't understand. */
1118 #define __DRI_CTX_ERROR_UNKNOWN_FLAG		6
1119 /*@}*/
1120 
1121 
1122 /**
1123  * This extension provides functionality to enable various EGLImage
1124  * extensions.
1125  */
1126 #define __DRI_IMAGE "DRI_IMAGE"
1127 #define __DRI_IMAGE_VERSION 22
1128 
1129 /* __DRI_IMAGE_FORMAT_* tokens are no longer exported */
1130 
1131 #define __DRI_IMAGE_USE_SHARE		0x0001
1132 #define __DRI_IMAGE_USE_SCANOUT		0x0002
1133 #define __DRI_IMAGE_USE_CURSOR		0x0004 /* Deprecated */
1134 #define __DRI_IMAGE_USE_LINEAR		0x0008
1135 /* The buffer will only be read by an external process after SwapBuffers,
1136  * in contrary to gbm buffers, front buffers and fake front buffers, which
1137  * could be read after a flush."
1138  */
1139 #define __DRI_IMAGE_USE_BACKBUFFER      0x0010
1140 #define __DRI_IMAGE_USE_PROTECTED       0x0020
1141 #define __DRI_IMAGE_USE_PRIME_BUFFER    0x0040
1142 #define __DRI_IMAGE_USE_FRONT_RENDERING 0x0080
1143 
1144 
1145 #define __DRI_IMAGE_TRANSFER_READ            0x1
1146 #define __DRI_IMAGE_TRANSFER_WRITE           0x2
1147 #define __DRI_IMAGE_TRANSFER_READ_WRITE      \
1148         (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)
1149 
1150 /**
1151  * Extra fourcc formats used internally to Mesa with createImageFromNames.
1152  * The externally-available fourccs are defined by drm_fourcc.h (DRM_FORMAT_*)
1153  * and WL_DRM_FORMAT_* from wayland_drm.h.
1154  *
1155  * \since 5
1156  */
1157 
1158 #define __DRI_IMAGE_FOURCC_SARGB8888	0x83324258
1159 #define __DRI_IMAGE_FOURCC_SABGR8888	0x84324258
1160 #define __DRI_IMAGE_FOURCC_SXRGB8888	0x85324258
1161 
1162 /**
1163  * Queryable on images created by createImageFromNames.
1164  *
1165  * RGB and RGBA might be usable directly as images, but it's still
1166  * recommended to call fromPlanar with plane == 0.
1167  *
1168  * Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create
1169  * usable sub-images, sampling from images return raw YUV data and
1170  * color conversion needs to be done in the shader.
1171  *
1172  * \since 5
1173  */
1174 
1175 #define __DRI_IMAGE_COMPONENTS_RGB	0x3001
1176 #define __DRI_IMAGE_COMPONENTS_RGBA	0x3002
1177 #define __DRI_IMAGE_COMPONENTS_Y_U_V	0x3003
1178 #define __DRI_IMAGE_COMPONENTS_Y_UV	0x3004
1179 #define __DRI_IMAGE_COMPONENTS_Y_XUXV	0x3005
1180 #define __DRI_IMAGE_COMPONENTS_Y_UXVX	0x3008
1181 #define __DRI_IMAGE_COMPONENTS_AYUV	0x3009
1182 #define __DRI_IMAGE_COMPONENTS_XYUV	0x300A
1183 #define __DRI_IMAGE_COMPONENTS_R	0x3006
1184 #define __DRI_IMAGE_COMPONENTS_RG	0x3007
1185 
1186 
1187 /**
1188  * queryImage attributes
1189  */
1190 
1191 #define __DRI_IMAGE_ATTRIB_STRIDE	0x2000
1192 #define __DRI_IMAGE_ATTRIB_HANDLE	0x2001
1193 #define __DRI_IMAGE_ATTRIB_NAME		0x2002
1194 #define __DRI_IMAGE_ATTRIB_FORMAT	0x2003 /* available in versions 3+ */
1195 #define __DRI_IMAGE_ATTRIB_WIDTH	0x2004 /* available in versions 4+ */
1196 #define __DRI_IMAGE_ATTRIB_HEIGHT	0x2005
1197 #define __DRI_IMAGE_ATTRIB_COMPONENTS	0x2006 /* available in versions 5+ */
1198 #define __DRI_IMAGE_ATTRIB_FD           0x2007 /* available in versions
1199                                                 * 7+. Each query will return a
1200                                                 * new fd. */
1201 #define __DRI_IMAGE_ATTRIB_FOURCC       0x2008 /* available in versions 11 */
1202 #define __DRI_IMAGE_ATTRIB_NUM_PLANES   0x2009 /* available in versions 11 */
1203 
1204 #define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
1205 #define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */
1206 #define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */
1207 #define __DRI_IMAGE_ATTRIB_COMPRESSION_RATE 0x200D /* available in versions 22 */
1208 
1209 enum __DRIYUVColorSpace {
1210    __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
1211    __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
1212    __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
1213    __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
1214 };
1215 
1216 enum __DRISampleRange {
1217    __DRI_YUV_RANGE_UNDEFINED = 0,
1218    __DRI_YUV_FULL_RANGE = 0x3282,
1219    __DRI_YUV_NARROW_RANGE = 0x3283
1220 };
1221 
1222 enum __DRIChromaSiting {
1223    __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
1224    __DRI_YUV_CHROMA_SITING_0 = 0x3284,
1225    __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
1226 };
1227 
1228 enum __DRIFixedRateCompression {
1229   __DRI_FIXED_RATE_COMPRESSION_NONE = 0x34B1,
1230   __DRI_FIXED_RATE_COMPRESSION_DEFAULT = 0x34B2,
1231 
1232   __DRI_FIXED_RATE_COMPRESSION_1BPC = 0x34B4,
1233   __DRI_FIXED_RATE_COMPRESSION_2BPC = 0x34B5,
1234   __DRI_FIXED_RATE_COMPRESSION_3BPC = 0x34B6,
1235   __DRI_FIXED_RATE_COMPRESSION_4BPC = 0x34B7,
1236   __DRI_FIXED_RATE_COMPRESSION_5BPC = 0x34B8,
1237   __DRI_FIXED_RATE_COMPRESSION_6BPC = 0x34B9,
1238   __DRI_FIXED_RATE_COMPRESSION_7BPC = 0x34BA,
1239   __DRI_FIXED_RATE_COMPRESSION_8BPC = 0x34BB,
1240   __DRI_FIXED_RATE_COMPRESSION_9BPC = 0x34BC,
1241   __DRI_FIXED_RATE_COMPRESSION_10BPC = 0x34BD,
1242   __DRI_FIXED_RATE_COMPRESSION_11BPC = 0x34BE,
1243   __DRI_FIXED_RATE_COMPRESSION_12BPC = 0x34BF,
1244 };
1245 
1246 /**
1247  * \name Reasons that __DRIimageExtensionRec::createImageFromTexture or
1248  * __DRIimageExtensionRec::createImageFromDmaBufs might fail
1249  */
1250 /*@{*/
1251 /** Success! */
1252 #define __DRI_IMAGE_ERROR_SUCCESS       0
1253 
1254 /** Memory allocation failure */
1255 #define __DRI_IMAGE_ERROR_BAD_ALLOC     1
1256 
1257 /** Client requested an invalid attribute */
1258 #define __DRI_IMAGE_ERROR_BAD_MATCH     2
1259 
1260 /** Client requested an invalid texture object */
1261 #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
1262 
1263 /** Client requested an invalid pitch and/or offset */
1264 #define __DRI_IMAGE_ERROR_BAD_ACCESS    4
1265 /*@}*/
1266 
1267 /**
1268  * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
1269  */
1270 /*@{*/
1271 #define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
1272 /*@}*/
1273 
1274 /**
1275  * blitImage flags
1276  */
1277 
1278 #define __BLIT_FLAG_FLUSH		0x0001
1279 #define __BLIT_FLAG_FINISH		0x0002
1280 
1281 /**
1282  * Flags for createImageFromDmaBufs
1283  */
1284 #define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001
1285 #define __DRI_IMAGE_PRIME_LINEAR_BUFFER    0x00000002
1286 
1287 /**
1288  * queryDmaBufFormatModifierAttribs attributes
1289  */
1290 
1291 /* Available in version 16 */
1292 #define __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT   0x0001
1293 
1294 typedef struct __DRIimageRec          __DRIimage;
1295 typedef struct __DRIimageExtensionRec __DRIimageExtension;
1296 struct __DRIimageExtensionRec {
1297     __DRIextension base;
1298 
1299     void (*destroyImage)(__DRIimage *image);
1300 
1301    unsigned char (*queryImage)(__DRIimage *image, int attrib, int *value);
1302 
1303    /**
1304     * The new __DRIimage will share the content with the old one, see dup(2).
1305     */
1306    __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
1307 
1308    /**
1309     * Validate that a __DRIimage can be used a certain way.
1310     *
1311     * \since 2
1312     */
1313    unsigned char (*validateUsage)(__DRIimage *image, unsigned int use);
1314 
1315    /**
1316     * Create an image from a series of GEM names; uses FourCC for format
1317     * and byte stride.
1318     *
1319     * \since 5
1320     */
1321    __DRIimage *(*createImageFromNames)(__DRIscreen *screen,
1322                                        int width, int height, int fourcc,
1323                                        int *names, int num_names,
1324                                        int *strides, int *offsets,
1325                                        void *loaderPrivate);
1326 
1327    /**
1328     * Create an image out of a sub-region of a parent image.  This
1329     * entry point lets us create individual __DRIimages for different
1330     * planes in a planar buffer (typically yuv), for example.  While a
1331     * sub-image shares the underlying buffer object with the parent
1332     * image and other sibling sub-images, the life times of parent and
1333     * sub-images are not dependent.  Destroying the parent or a
1334     * sub-image doesn't affect other images.  The underlying buffer
1335     * object is free when no __DRIimage remains that references it.
1336     *
1337     * Sub-images may overlap, but rendering to overlapping sub-images
1338     * is undefined.
1339     *
1340     * \since 5
1341     */
1342     __DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
1343                               void *loaderPrivate);
1344 
1345     /**
1346      * Create image from texture.
1347      *
1348      * \since 6
1349      */
1350    __DRIimage *(*createImageFromTexture)(__DRIcontext *context,
1351                                          int target,
1352                                          unsigned texture,
1353                                          int depth,
1354                                          int level,
1355                                          unsigned *error,
1356                                          void *loaderPrivate);
1357 
1358    /**
1359     * Blit a part of a __DRIimage to another and flushes
1360     *
1361     * flush_flag:
1362     *    0:                  no flush
1363     *    __BLIT_FLAG_FLUSH:  flush after the blit operation
1364     *    __BLIT_FLAG_FINISH: flush and wait the blit finished
1365     *
1366     * \since 9
1367     */
1368    void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
1369                      int dstx0, int dsty0, int dstwidth, int dstheight,
1370                      int srcx0, int srcy0, int srcwidth, int srcheight,
1371                      int flush_flag);
1372 
1373    /**
1374     * Query for general capabilities of the driver that concern
1375     * buffer sharing and image importing.
1376     *
1377     * \since 10
1378     */
1379    int (*getCapabilities)(__DRIscreen *screen);
1380 
1381    /**
1382     * Returns a map of the specified region of a __DRIimage for the specified usage.
1383     *
1384     * flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the
1385     * mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ
1386     * is not included in the flags, the buffer content at map time is
1387     * undefined. Users wanting to modify the mapping must include
1388     * __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not
1389     * included, behaviour when writing the mapping is undefined.
1390     *
1391     * Returns the byte stride in *stride, and an opaque pointer to data
1392     * tracking the mapping in **data, which must be passed to unmapImage().
1393     *
1394     * \since 12
1395     */
1396    void *(*mapImage)(__DRIcontext *context, __DRIimage *image,
1397                      int x0, int y0, int width, int height,
1398                      unsigned int flags, int *stride, void **data);
1399 
1400    /**
1401     * Unmap a previously mapped __DRIimage
1402     *
1403     * \since 12
1404     */
1405    void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);
1406 
1407    /*
1408     * dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers.
1409     *
1410     * \param max      Maximum number of formats that can be accomodated into
1411     *                 \param formats. If zero, no formats are returned -
1412     *                 instead, the driver returns the total number of
1413     *                 supported dmabuf formats in \param count.
1414     * \param formats  Buffer to fill formats into.
1415     * \param count    Count of formats returned, or, total number of
1416     *                 supported formats in case \param max is zero.
1417     *
1418     * Returns true on success.
1419     *
1420     * \since 15
1421     */
1422    bool (*queryDmaBufFormats)(__DRIscreen *screen, int max, int *formats,
1423                               int *count);
1424 
1425    /*
1426     * dmabuf format modifier query for a given format to support
1427     * EGL_EXT_image_dma_buf_import_modifiers.
1428     *
1429     * \param fourcc    The format to query modifiers for. If this format
1430     *                  is not supported by the driver, return false.
1431     * \param max       Maximum number of modifiers that can be accomodated in
1432     *                  \param modifiers. If zero, no modifiers are returned -
1433     *                  instead, the driver returns the total number of
1434     *                  modifiers for \param format in \param count.
1435     * \param modifiers Buffer to fill modifiers into.
1436     * \param count     Count of the modifiers returned, or, total number of
1437     *                  supported modifiers for \param fourcc in case
1438     *                  \param max is zero.
1439     *
1440     * Returns true upon success.
1441     *
1442     * \since 15
1443     */
1444    bool (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc, int max,
1445                                 uint64_t *modifiers,
1446                                 unsigned int *external_only, int *count);
1447 
1448    /**
1449     * dmabuf format modifier attribute query for a given format and modifier.
1450     *
1451     * \param fourcc    The format to query. If this format is not supported by
1452     *                  the driver, return false.
1453     * \param modifier  The modifier to query. If this format+modifier is not
1454     *                  supported by the driver, return false.
1455     * \param attrib    The __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB to query.
1456     * \param value     A pointer to where to store the result of the query.
1457     *
1458     * Returns true upon success.
1459     *
1460     * \since 16
1461     */
1462    bool (*queryDmaBufFormatModifierAttribs)(__DRIscreen *screen,
1463                                             uint32_t fourcc, uint64_t modifier,
1464                                             int attrib, uint64_t *value);
1465 
1466    /**
1467     * Create a DRI image from the given renderbuffer.
1468     *
1469     * \param context       the current DRI context
1470     * \param renderbuffer  the GL name of the renderbuffer
1471     * \param loaderPrivate for callbacks into the loader related to the image
1472     * \param error         will be set to one of __DRI_IMAGE_ERROR_xxx
1473     * \return the newly created image on success, or NULL otherwise
1474     */
1475     __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
1476                                                int renderbuffer,
1477                                                void *loaderPrivate,
1478                                                unsigned *error);
1479 
1480    /**
1481     * Creates a DRI image from an array of dmabuf fds and their modifiers.
1482     *
1483     * See __DRI_IMAGE_*_FLAG for valid definitions of flags.
1484     */
1485    __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
1486                                          int width, int height, int fourcc,
1487                                          uint64_t modifier,
1488                                          int *fds, int num_fds,
1489                                          int *strides, int *offsets,
1490                                          enum __DRIYUVColorSpace color_space,
1491                                          enum __DRISampleRange sample_range,
1492                                          enum __DRIChromaSiting horiz_siting,
1493                                          enum __DRIChromaSiting vert_siting,
1494                                          uint32_t flags,
1495                                          unsigned *error,
1496                                          void *loaderPrivate);
1497 
1498    /**
1499     * Creates an image with implementation's favorite modifiers and the
1500     * provided usage flags.
1501     *
1502     * Passing either zero modifiers, or a modifier list consisting only
1503     * of DRM_FORMAT_MOD_INVALID, allows the implementation to select a
1504     * layout with implicit modifiers.
1505     *
1506     * The created image should be destroyed with destroyImage().
1507     *
1508     * Returns the new DRIimage. The chosen modifier can be obtained later on
1509     * and passed back to things like the kernel's AddFB2 interface.
1510     *
1511     * \sa __DRIimageRec::createImage
1512     *
1513     * \since 19
1514     */
1515    __DRIimage *(*createImage)(__DRIscreen *screen,
1516                               int width, int height, int format,
1517                               const uint64_t *modifiers,
1518                               const unsigned int modifier_count,
1519                               unsigned int use,
1520                               void *loaderPrivate);
1521 
1522    /**
1523     * Set an in-fence-fd on the image.  If a fence-fd is already set
1524     * (but not yet consumed), the existing and new fence will be merged
1525     *
1526     * This does *not* take ownership of the fd.  The fd does not need
1527     * to be kept alive once the call has returned.
1528     *
1529     * \since 21
1530     */
1531    void (*setInFenceFd)(__DRIimage *image, int fd);
1532 
1533    /*
1534     * Query supported compression rates for a given format for
1535     * EGL_EXT_surface_compression.
1536     *
1537     * \param config   Config for which to query the supported compression
1538     *                 rates.
1539     * \param max      Maximum number of rates that can be accomodated into
1540     *                 \param rates. If zero, no rates are returned -
1541     *                 instead, the driver returns the total number of
1542     *                 supported compression rates in \param count.
1543     * \param rates    Buffer to fill rates into.
1544     * \param count    Count of rates returned, or, total number of
1545     *                 supported rates in case \param max is zero.
1546     *
1547     * Returns true on success.
1548     *
1549     * \since 22
1550     */
1551    bool (*queryCompressionRates)(__DRIscreen *screen, const __DRIconfig *config,
1552                                  int max, enum __DRIFixedRateCompression *rates,
1553                                  int *count);
1554 
1555    /*
1556     * Query list of modifiers that are associated with given fixed-rate
1557     * compression bitrate.
1558     *
1559     * \param format    The format to query
1560     * \param rate      Compression rate to query for
1561     * \param max       Maximum number of modifiers that can be accomodated in
1562     *                  \param modifiers. If zero, no modifiers are returned -
1563     *                  instead, the driver returns the total number of
1564     *                  modifiers for \param format in \param count.
1565     * \param modifiers Buffer to fill modifiers into.
1566     * \param count     Count of the modifiers returned, or, total number of
1567     *                  supported modifiers for \param fourcc in case
1568     *                  \param max is zero.
1569     *
1570     * Returns true on success.
1571     *
1572     * \since 22
1573     */
1574    bool (*queryCompressionModifiers)(__DRIscreen *screen, uint32_t format,
1575                                      enum __DRIFixedRateCompression rate,
1576                                      int max, uint64_t *modifiers, int *count);
1577 };
1578 
1579 
1580 /**
1581  * This extension must be implemented by the loader and passed to the
1582  * driver at screen creation time.  The EGLImage entry points in the
1583  * various client APIs take opaque EGLImage handles and use this
1584  * extension to map them to a __DRIimage.  At version 1, this
1585  * extensions allows mapping EGLImage pointers to __DRIimage pointers,
1586  * but future versions could support other EGLImage-like, opaque types
1587  * with new lookup functions.
1588  */
1589 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
1590 #define __DRI_IMAGE_LOOKUP_VERSION 2
1591 
1592 typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
1593 struct __DRIimageLookupExtensionRec {
1594     __DRIextension base;
1595 
1596     /**
1597      * Check if EGLImage is associated with the EGL display before lookup with
1598      * lookupEGLImageValidated(). It will hold EGLDisplay.Mutex, so is separated
1599      * out from lookupEGLImageValidated() to avoid deadlock.
1600      */
1601     unsigned char (*validateEGLImage)(void *image, void *loaderPrivate);
1602 
1603     /**
1604      * Lookup EGLImage after validateEGLImage(). No lock in this function.
1605      */
1606     __DRIimage *(*lookupEGLImageValidated)(void *image, void *loaderPrivate);
1607 };
1608 
1609 /**
1610  * This extension allows for common DRI2 options
1611  */
1612 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
1613 #define __DRI2_CONFIG_QUERY_VERSION 2
1614 
1615 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
1616 struct __DRI2configQueryExtensionRec {
1617    __DRIextension base;
1618 
1619    int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);
1620    int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
1621    int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
1622    int (*configQuerys)(__DRIscreen *screen, const char *var, char **val);
1623 };
1624 
1625 /**
1626  * Robust context driver extension.
1627  *
1628  * Existence of this extension means the driver can accept the
1629  * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
1630  * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
1631  * \c __DRIdri2ExtensionRec::createContextAttribs.
1632  *
1633  * Used by the X server.
1634  */
1635 #define __DRI2_ROBUSTNESS "DRI_Robustness"
1636 #define __DRI2_ROBUSTNESS_VERSION 1
1637 
1638 typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
1639 struct __DRIrobustnessExtensionRec {
1640    __DRIextension base;
1641 };
1642 
1643 /**
1644  * No-error context driver extension (deprecated).
1645  *
1646  * Existence of this extension means the driver can accept the
1647  * __DRI_CTX_FLAG_NO_ERROR flag.
1648  *
1649  * This extension is deprecated, and modern Mesa knows that it's always
1650  * supported.
1651  *
1652  * Not used by the X server.
1653  */
1654 #define __DRI2_NO_ERROR "DRI_NoError"
1655 #define __DRI2_NO_ERROR_VERSION 1
1656 
1657 typedef struct __DRInoErrorExtensionRec {
1658    __DRIextension base;
1659 } __DRInoErrorExtension;
1660 
1661 /*
1662  * Flush control driver extension.
1663  *
1664  * Existence of this extension means the driver can accept the
1665  * \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in
1666  * \c __DRIdri2ExtensionRec::createContextAttribs.
1667  *
1668  * Used by the X server.
1669  */
1670 #define __DRI2_FLUSH_CONTROL "DRI_FlushControl"
1671 #define __DRI2_FLUSH_CONTROL_VERSION 1
1672 
1673 typedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension;
1674 struct __DRI2flushControlExtensionRec {
1675    __DRIextension base;
1676 };
1677 
1678 /**
1679  * DRI config options extension.
1680  *
1681  * This extension provides the XML string containing driver options for use by
1682  * the loader in supporting the driconf application.
1683  *
1684  * v2:
1685  * - Add the getXml getter function which allows the driver more flexibility in
1686  *   how the XML is provided.
1687  * - Deprecate the direct xml pointer. It is only provided as a fallback for
1688  *   older versions of libGL and must not be used by clients that are aware of
1689  *   the newer version. Future driver versions may set it to NULL.
1690  */
1691 #define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
1692 #define __DRI_CONFIG_OPTIONS_VERSION 2
1693 
1694 typedef struct __DRIconfigOptionsExtensionRec {
1695    __DRIextension base;
1696    const char *xml; /**< deprecated since v2, use getXml instead */
1697 
1698    /**
1699     * Get an XML string that describes available driver options for use by a
1700     * config application.
1701     *
1702     * The returned string must be heap-allocated. The caller is responsible for
1703     * freeing it.
1704     */
1705    char *(*getXml)(const char *driver_name);
1706 } __DRIconfigOptionsExtension;
1707 
1708 /**
1709  * Query renderer driver extension
1710  *
1711  * This allows the window system layer (either EGL or GLX) to query aspects of
1712  * hardware and driver support without creating a context.
1713  */
1714 #define __DRI2_RENDERER_VENDOR_ID                             0x0000
1715 #define __DRI2_RENDERER_DEVICE_ID                             0x0001
1716 #define __DRI2_RENDERER_VERSION                               0x0002
1717 #define __DRI2_RENDERER_ACCELERATED                           0x0003
1718 #define __DRI2_RENDERER_VIDEO_MEMORY                          0x0004
1719 #define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE           0x0005
1720 #define __DRI2_RENDERER_PREFERRED_PROFILE                     0x0006
1721 #define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION           0x0007
1722 #define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION  0x0008
1723 #define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION             0x0009
1724 #define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION            0x000a
1725 
1726 #define __DRI2_RENDERER_PREFER_BACK_BUFFER_REUSE              0x000f
1727 
1728 /**
1729  * Image Loader extension. Drivers use this to allocate color buffers
1730  */
1731 
1732 /**
1733  * See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask.
1734  */
1735 enum __DRIimageBufferMask {
1736    __DRI_IMAGE_BUFFER_BACK = (1 << 0),
1737    __DRI_IMAGE_BUFFER_FRONT = (1 << 1),
1738 
1739    /**
1740     * A buffer shared between application and compositor. The buffer may be
1741     * simultaneously accessed by each.
1742     *
1743     * A shared buffer is equivalent to an EGLSurface whose EGLConfig contains
1744     * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as
1745     * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
1746     * EGL_SINGLE_BUFFER.
1747     *
1748     * If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no
1749     * other bits. As a corollary, a __DRIdrawable that has a "shared" buffer
1750     * has no front nor back buffer.
1751     *
1752     * The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only
1753     * if:
1754     *     - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER.
1755     *     - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER.
1756     *     - The EGLConfig of the drawable EGLSurface contains
1757     *       EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.
1758     *     - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER.
1759     *       Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as
1760     *       opposed to any pending, requested change to EGL_RENDER_BUFFER) is
1761     *       EGL_SINGLE_BUFFER. (See the EGL 1.5 and
1762     *       EGL_KHR_mutable_render_buffer spec for details about "pending" vs
1763     *       "active" EGL_RENDER_BUFFER state).
1764     *
1765     * A shared buffer is similar to a front buffer in that all rendering to the
1766     * buffer should appear promptly on the screen. It is different from
1767     * a front buffer in that its behavior is independent from the
1768     * GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the
1769     * __DRIdrawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all
1770     * rendering should appear promptly on the screen if GL_DRAW_BUFFER is not
1771     * GL_NONE.
1772     *
1773     * The difference between a shared buffer and a front buffer is motivated
1774     * by the constraints of Android and OpenGL ES. OpenGL ES does not support
1775     * front-buffer rendering. Android's SurfaceFlinger protocol provides the
1776     * EGL driver only a back buffer and no front buffer. The shared buffer
1777     * mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though
1778     * EGL that allows Android OpenGL ES applications to render to what is
1779     * effectively the front buffer, a backdoor that required no change to the
1780     * OpenGL ES API and little change to the SurfaceFlinger API.
1781     */
1782    __DRI_IMAGE_BUFFER_SHARED = (1 << 2),
1783 };
1784 
1785 struct __DRIimageList {
1786    uint32_t image_mask;
1787    __DRIimage *back;
1788    __DRIimage *front;
1789 };
1790 
1791 #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
1792 #define __DRI_IMAGE_LOADER_VERSION 4
1793 
1794 struct __DRIimageLoaderExtensionRec {
1795     __DRIextension base;
1796 
1797    /**
1798     * Allocate color buffers.
1799     *
1800     * \param driDrawable
1801     * \param width              Width of allocated buffers
1802     * \param height             Height of allocated buffers
1803     * \param format             one of __DRI_IMAGE_FORMAT_*
1804     * \param stamp              Address of variable to be updated when
1805     *                           getBuffers must be called again
1806     * \param loaderPrivate      The loaderPrivate for driDrawable
1807     * \param buffer_mask        Set of buffers to allocate. A bitmask of
1808     *                           __DRIimageBufferMask.
1809     * \param buffers            Returned buffers
1810     */
1811    int (*getBuffers)(__DRIdrawable *driDrawable,
1812                      unsigned int format,
1813                      uint32_t *stamp,
1814                      void *loaderPrivate,
1815                      uint32_t buffer_mask,
1816                      struct __DRIimageList *buffers);
1817 
1818     /**
1819      * Flush pending front-buffer rendering
1820      *
1821      * Any rendering that has been performed to the
1822      * fake front will be flushed to the front
1823      *
1824      * \param driDrawable    Drawable whose front-buffer is to be flushed
1825      * \param loaderPrivate  Loader's private data that was previously passed
1826      *                       into __DRIdri2ExtensionRec::createNewDrawable
1827      */
1828     void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
1829 
1830     /**
1831      * Return a loader capability value. If the loader doesn't know the enum,
1832      * it will return 0.
1833      *
1834      * \since 2
1835      */
1836     unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
1837 
1838     /**
1839      * Flush swap buffers
1840      *
1841      * Make sure any outstanding swap buffers have been submitted to the
1842      * device.
1843      *
1844      * \param driDrawable    Drawable whose swaps need to be flushed
1845      * \param loaderPrivate  Loader's private data that was previously passed
1846      *                       into __DRIdri2ExtensionRec::createNewDrawable
1847      *
1848      * \since 3
1849      */
1850     void (*flushSwapBuffers)(__DRIdrawable *driDrawable, void *loaderPrivate);
1851 
1852     /**
1853      * Clean up any loader state associated with an image.
1854      *
1855      * \param loaderPrivate  Loader's private data that was previously passed
1856      *                       into a __DRIimageExtensionRec::createImage function
1857      * \since 4
1858      */
1859     void (*destroyLoaderImageState)(void *loaderPrivate);
1860 };
1861 
1862 /**
1863  * Main DRI3 interface extension.
1864  *
1865  * Not used by the X server.
1866  */
1867 
1868 #define __DRI_IMAGE_DRIVER           "DRI_IMAGE_DRIVER"
1869 #define __DRI_IMAGE_DRIVER_VERSION   2
1870 
1871 struct __DRIimageDriverExtensionRec {
1872    __DRIextension               base;
1873 
1874    /* Common DRI functions, shared with DRI2 */
1875    __DRIcreateNewScreen2Func            createNewScreen2;
1876    __DRIcreateNewDrawableFunc           createNewDrawable;
1877    __DRIcreateContextAttribsFunc        createContextAttribs;
1878    __DRIgetAPIMaskFunc                  getAPIMask;
1879    __DRIcreateNewScreen3Func            createNewScreen3;
1880 };
1881 
1882 /**
1883  * Background callable loader extension.
1884  *
1885  * Loaders expose this extension to indicate to drivers that they are capable
1886  * of handling callbacks from the driver's background drawing threads.
1887  */
1888 #define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"
1889 #define __DRI_BACKGROUND_CALLABLE_VERSION 1
1890 
1891 typedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension;
1892 struct __DRIbackgroundCallableExtensionRec {
1893    __DRIextension base;
1894 
1895    /**
1896     * Indicate that this thread is being used by the driver as a background
1897     * drawing thread which may make callbacks to the loader.
1898     *
1899     * \param loaderPrivate is the value that was passed to to the driver when
1900     * the context was created.  This can be used by the loader to identify
1901     * which context any callbacks are associated with.
1902     *
1903     * If this function is called more than once from any given thread, each
1904     * subsequent call overrides the loaderPrivate data that was passed in the
1905     * previous call.  The driver can take advantage of this to re-use a
1906     * background thread to perform drawing on behalf of multiple contexts.
1907     *
1908     * It is permissible for the driver to call this function from a
1909     * non-background thread (i.e. a thread that has already been bound to a
1910     * context using __DRIcoreExtensionRec::bindContext()); when this happens,
1911     * the \c loaderPrivate pointer must be equal to the pointer that was
1912     * passed to the driver when the currently bound context was created.
1913     *
1914     * This call should execute quickly enough that the driver can call it with
1915     * impunity whenever a background thread starts performing drawing
1916     * operations (e.g. it should just set a thread-local variable).
1917     */
1918    void (*setBackgroundContext)(void *loaderPrivate);
1919 
1920    /**
1921     * Indicate that it is multithread safe to use glthread.  For GLX/EGL
1922     * platforms using Xlib, that involves calling XInitThreads, before
1923     * opening an X display.
1924     *
1925     * Note: only supported if extension version is at least 2.
1926     *
1927     * \param loaderPrivate is the value that was passed to to the driver when
1928     * the context was created.  This can be used by the loader to identify
1929     * which context any callbacks are associated with.
1930     */
1931    unsigned char (*isThreadSafe)(void *loaderPrivate);
1932 };
1933 
1934 /**
1935  * The driver portion of EGL_KHR_mutable_render_buffer.
1936  *
1937  * If the driver creates a __DRIconfig with
1938  * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension.
1939  *
1940  * To support this extension:
1941  *
1942  *    - The driver should create at least one __DRIconfig with
1943  *      __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but
1944  *      not required.
1945  *
1946  *    - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if
1947  *      returned by __DRIimageLoaderExtension:getBuffers().
1948  *
1949  *    - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call
1950  *      __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() in
1951  *      response to glFlush and glFinish.  (This requirement is not documented
1952  *      in EGL_KHR_mutable_render_buffer, but is a de-facto requirement in the
1953  *      Android ecosystem. Android applications expect that glFlush will
1954  *      immediately display the buffer when in shared buffer mode, and Android
1955  *      drivers comply with this expectation).  It :may: call
1956  *      displaySharedBuffer() more often than required.
1957  *
1958  *    - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the
1959  *      buffer is always in a format compatible for display because the
1960  *      display engine (usually SurfaceFlinger or hwcomposer) may display the
1961  *      image at any time, even concurrently with 3D rendering. For example,
1962  *      display hardware and the GL hardware may be able to access the buffer
1963  *      simultaneously. In particular, if the buffer is compressed then take
1964  *      care that SurfaceFlinger and hwcomposer can consume the compression
1965  *      format.
1966  *
1967  * Not used by the X server.
1968  *
1969  * \see __DRI_IMAGE_BUFFER_SHARED
1970  * \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER
1971  * \see __DRI_MUTABLE_RENDER_BUFFER_LOADER
1972  */
1973 #define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver"
1974 #define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 1
1975 
1976 typedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension;
1977 struct __DRImutableRenderBufferDriverExtensionRec {
1978    __DRIextension base;
1979 };
1980 
1981 /**
1982  * The loader portion of EGL_KHR_mutable_render_buffer.
1983  *
1984  * Requires loader extension DRI_IMAGE_LOADER, through which the loader sends
1985  * __DRI_IMAGE_BUFFER_SHARED to the driver.
1986  *
1987  * Not used by the X server.
1988  *
1989  * \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER
1990  */
1991 #define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader"
1992 #define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 1
1993 
1994 typedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension;
1995 struct __DRImutableRenderBufferLoaderExtensionRec {
1996    __DRIextension base;
1997 
1998    /**
1999     * Inform the display engine (that is, SurfaceFlinger and/or hwcomposer)
2000     * that the __DRIdrawable has new content.
2001     *
2002     * The display engine may ignore this call, for example, if it continually
2003     * refreshes and displays the buffer on every frame, as in
2004     * EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display
2005     * engine may refresh and display the buffer only in frames in which the
2006     * driver calls this.
2007     *
2008     * If the fence_fd is not -1, then the display engine will display the
2009     * buffer only after the fence signals.
2010     *
2011     * The drawable's current __DRIimageBufferMask, as returned by
2012     * __DRIimageLoaderExtension::getBuffers(), must be
2013     * __DRI_IMAGE_BUFFER_SHARED.
2014     */
2015    void (*displaySharedBuffer)(__DRIdrawable *drawable, int fence_fd,
2016                                void *loaderPrivate);
2017 };
2018 
2019 /* Mesa-internal interface between the GLX, GBM, and EGL DRI driver loaders, and
2020  * the gallium dri_util.c code.
2021  */
2022 
2023 typedef struct __DRImesaCoreExtensionRec __DRImesaCoreExtension;
2024 
2025 #define __DRI_MESA "DRI_Mesa"
2026 #define __DRI_MESA_VERSION 2
2027 
2028 struct dri_screen;
2029 
2030 /**  Core struct that appears alongside __DRI_CORE for Mesa-internal usage.
2031  * Implemented in the top-level dri/drisw/kopper extension list.
2032  */
2033 struct __DRImesaCoreExtensionRec {
2034    __DRIextension base;
2035 
2036    /* Version string for verifying that the DRI driver is from the same build as
2037     * the loader.
2038     */
2039 #define MESA_INTERFACE_VERSION_STRING PACKAGE_VERSION MESA_GIT_SHA1
2040    const char *version_string;
2041 
2042 
2043    __DRIcreateContextAttribsFunc createContext;
2044 
2045    /* driver function for finishing initialization inside createNewScreen(). */
2046    const __DRIconfig **(*initScreen)(struct dri_screen *screen, bool driver_name_is_inferred);
2047 
2048    int (*queryCompatibleRenderOnlyDeviceFd)(int kms_only_fd);
2049 
2050    /* Screen creation function regardless of DRI2, image, or swrast backend.
2051     * (Nothing uses the old __DRI_CORE screen create).
2052     *
2053     * If not associated with a DRM fd (non-swkms swrast), the fd argument should
2054     * be -1.
2055     */
2056    /* version 2 */
2057    __DRIcreateNewScreen3Func createNewScreen3;
2058 };
2059 
2060 #endif /* MESA_INTERFACE_H */
2061