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