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