Debian Codegraph @

include/GL/internal/dri_interface.h

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