2 * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2007-2008 Red Hat, Inc.
4 * (C) Copyright IBM Corporation 2004
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:
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
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.
28 * \file dri_interface.h
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.
35 * \author Kevin E. Martin <kevin@precisioninsight.com>
36 * \author Ian Romanick <idr@us.ibm.com>
37 * \author Kristian Høgsberg <krh@redhat.com>
40 #ifndef DRI_INTERFACE_H
41 #define DRI_INTERFACE_H
46 typedef unsigned int drm_context_t
;
47 typedef unsigned int drm_drawable_t
;
48 typedef struct drm_clip_rect drm_clip_rect_t
;
56 * \name DRI interface structures
58 * The following structures define the interface between the GLX client
59 * side library and the DRI (direct rendering infrastructure).
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
;
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 typedef struct __DRI2bufferDamageExtensionRec __DRI2bufferDamageExtension
;
90 typedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension
;
91 typedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension
;
97 * Extension struct. Drivers 'inherit' from this struct by embedding
98 * it as the first element in the extension struct.
100 * We never break API in for a DRI extension. If we need to change
101 * the way things work in a non-backwards compatible manner, we
102 * introduce a new extension. During a transition period, we can
103 * leave both the old and the new extension in the driver, which
104 * allows us to move to the new interface without having to update the
105 * loader(s) in lock step.
107 * However, we can add entry points to an extension over time as long
108 * as we don't break the old ones. As we add entry points to an
109 * extension, we increase the version number. The corresponding
110 * #define can be used to guard code that accesses the new entry
111 * points at compile time and the version field in the extension
112 * struct can be used at run-time to determine how to use the
115 struct __DRIextensionRec
{
121 * The first set of extension are the screen extensions, returned by
122 * __DRIcore::getExtensions(). This entry point will return a list of
123 * extensions and the loader can use the ones it knows about by
124 * casting them to more specific extensions and advertising any GLX
125 * extensions the DRI extensions enables.
129 * Used by drivers to indicate support for setting the read drawable.
131 #define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
132 #define __DRI_READ_DRAWABLE_VERSION 1
135 * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
137 #define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
138 #define __DRI_COPY_SUB_BUFFER_VERSION 1
139 struct __DRIcopySubBufferExtensionRec
{
141 void (*copySubBuffer
)(__DRIdrawable
*drawable
, int x
, int y
, int w
, int h
);
145 * Used by drivers that implement the GLX_SGI_swap_control or
146 * GLX_MESA_swap_control extension.
148 #define __DRI_SWAP_CONTROL "DRI_SwapControl"
149 #define __DRI_SWAP_CONTROL_VERSION 1
150 struct __DRIswapControlExtensionRec
{
152 void (*setSwapInterval
)(__DRIdrawable
*drawable
, unsigned int inteval
);
153 unsigned int (*getSwapInterval
)(__DRIdrawable
*drawable
);
157 * Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
159 #define __DRI_FRAME_TRACKING "DRI_FrameTracking"
160 #define __DRI_FRAME_TRACKING_VERSION 1
161 struct __DRIframeTrackingExtensionRec
{
165 * Enable or disable frame usage tracking.
167 * \since Internal API version 20030317.
169 int (*frameTracking
)(__DRIdrawable
*drawable
, GLboolean enable
);
172 * Retrieve frame usage information.
174 * \since Internal API version 20030317.
176 int (*queryFrameTracking
)(__DRIdrawable
*drawable
,
177 int64_t * sbc
, int64_t * missedFrames
,
178 float * lastMissedUsage
, float * usage
);
183 * Used by drivers that implement the GLX_SGI_video_sync extension.
185 #define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
186 #define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
187 struct __DRImediaStreamCounterExtensionRec
{
191 * Wait for the MSC to equal target_msc, or, if that has already passed,
192 * the next time (MSC % divisor) is equal to remainder. If divisor is
193 * zero, the function will return as soon as MSC is greater than or equal
196 int (*waitForMSC
)(__DRIdrawable
*drawable
,
197 int64_t target_msc
, int64_t divisor
, int64_t remainder
,
198 int64_t * msc
, int64_t * sbc
);
201 * Get the number of vertical refreshes since some point in time before
202 * this function was first called (i.e., system start up).
204 int (*getDrawableMSC
)(__DRIscreen
*screen
, __DRIdrawable
*drawable
,
209 #define __DRI_TEX_OFFSET "DRI_TexOffset"
210 #define __DRI_TEX_OFFSET_VERSION 1
211 struct __DRItexOffsetExtensionRec
{
215 * Method to override base texture image with a driver specific 'offset'.
216 * The depth passed in allows e.g. to ignore the alpha channel of texture
217 * images where the non-alpha components don't occupy a whole texel.
219 * For GLX_EXT_texture_from_pixmap with AIGLX.
221 void (*setTexOffset
)(__DRIcontext
*pDRICtx
, GLint texname
,
222 unsigned long long offset
, GLint depth
, GLuint pitch
);
226 /* Valid values for format in the setTexBuffer2 function below. These
227 * values match the GLX tokens for compatibility reasons, but we
228 * define them here since the DRI interface can't depend on GLX. */
229 #define __DRI_TEXTURE_FORMAT_NONE 0x20D8
230 #define __DRI_TEXTURE_FORMAT_RGB 0x20D9
231 #define __DRI_TEXTURE_FORMAT_RGBA 0x20DA
233 #define __DRI_TEX_BUFFER "DRI_TexBuffer"
234 #define __DRI_TEX_BUFFER_VERSION 3
235 struct __DRItexBufferExtensionRec
{
239 * Method to override base texture image with the contents of a
242 * For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of
243 * setTexBuffer2 in version 2 of this interface
245 void (*setTexBuffer
)(__DRIcontext
*pDRICtx
,
247 __DRIdrawable
*pDraw
);
250 * Method to override base texture image with the contents of a
251 * __DRIdrawable, including the required texture format attribute.
253 * For GLX_EXT_texture_from_pixmap with AIGLX.
257 void (*setTexBuffer2
)(__DRIcontext
*pDRICtx
,
260 __DRIdrawable
*pDraw
);
262 * Method to release texture buffer in case some special platform
265 * For GLX_EXT_texture_from_pixmap with AIGLX.
269 void (*releaseTexBuffer
)(__DRIcontext
*pDRICtx
,
271 __DRIdrawable
*pDraw
);
275 * Used by drivers that implement DRI2
277 #define __DRI2_FLUSH "DRI2_Flush"
278 #define __DRI2_FLUSH_VERSION 4
280 #define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
281 #define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */
282 #define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2)
284 enum __DRI2throttleReason
{
285 __DRI2_THROTTLE_SWAPBUFFER
,
286 __DRI2_THROTTLE_COPYSUBBUFFER
,
287 __DRI2_THROTTLE_FLUSHFRONT
290 struct __DRI2flushExtensionRec
{
292 void (*flush
)(__DRIdrawable
*drawable
);
295 * Ask the driver to call getBuffers/getBuffersWithFormat before
296 * it starts rendering again.
298 * \param drawable the drawable to invalidate
302 void (*invalidate
)(__DRIdrawable
*drawable
);
305 * This function reduces the number of flushes in the driver by combining
306 * several operations into one call.
313 * \param context the context
314 * \param drawable the drawable to flush
315 * \param flags a combination of _DRI2_FLUSH_xxx flags
316 * \param throttle_reason the reason for throttling, 0 = no throttling
320 void (*flush_with_flags
)(__DRIcontext
*ctx
,
321 __DRIdrawable
*drawable
,
323 enum __DRI2throttleReason throttle_reason
);
328 * Extension that the driver uses to request
329 * throttle callbacks.
332 #define __DRI2_THROTTLE "DRI2_Throttle"
333 #define __DRI2_THROTTLE_VERSION 1
335 struct __DRI2throttleExtensionRec
{
337 void (*throttle
)(__DRIcontext
*ctx
,
338 __DRIdrawable
*drawable
,
339 enum __DRI2throttleReason reason
);
343 * Extension for EGL_ANDROID_blob_cache
346 #define __DRI2_BLOB "DRI2_Blob"
347 #define __DRI2_BLOB_VERSION 1
350 (*__DRIblobCacheSet
) (const void *key
, signed long keySize
,
351 const void *value
, signed long valueSize
);
354 (*__DRIblobCacheGet
) (const void *key
, signed long keySize
,
355 void *value
, signed long valueSize
);
357 struct __DRI2blobExtensionRec
{
361 * Set cache functions for setting and getting cache entries.
363 void (*set_cache_funcs
) (__DRIscreen
*screen
,
364 __DRIblobCacheSet set
, __DRIblobCacheGet get
);
368 * Extension for fences / synchronization objects.
371 #define __DRI2_FENCE "DRI2_Fence"
372 #define __DRI2_FENCE_VERSION 2
374 #define __DRI2_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffull
376 #define __DRI2_FENCE_FLAG_FLUSH_COMMANDS (1 << 0)
379 * \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities
382 #define __DRI_FENCE_CAP_NATIVE_FD 1
385 struct __DRI2fenceExtensionRec
{
389 * Create and insert a fence into the command stream of the context.
391 void *(*create_fence
)(__DRIcontext
*ctx
);
394 * Get a fence associated with the OpenCL event object.
395 * This can be NULL, meaning that OpenCL interoperability is not supported.
397 void *(*get_fence_from_cl_event
)(__DRIscreen
*screen
, intptr_t cl_event
);
402 void (*destroy_fence
)(__DRIscreen
*screen
, void *fence
);
405 * This function waits and doesn't return until the fence is signalled
406 * or the timeout expires. It returns true if the fence has been signaled.
408 * \param ctx the context where commands are flushed
409 * \param fence the fence
410 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags
411 * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE
413 GLboolean (*client_wait_sync
)(__DRIcontext
*ctx
, void *fence
,
414 unsigned flags
, uint64_t timeout
);
417 * This function enqueues a wait command into the command stream of
418 * the context and then returns. When the execution reaches the wait
419 * command, no further execution will be done in the context until
420 * the fence is signaled. This is a no-op if the device doesn't support
421 * parallel execution of contexts.
423 * \param ctx the context where the waiting is done
424 * \param fence the fence
425 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags that make
426 * sense with this function (right now there are none)
428 void (*server_wait_sync
)(__DRIcontext
*ctx
, void *fence
, unsigned flags
);
431 * Query for general capabilities of the driver that concern fences.
432 * Returns a bitmask of __DRI_FENCE_CAP_x
436 unsigned (*get_capabilities
)(__DRIscreen
*screen
);
439 * Create an fd (file descriptor) associated fence. If the fence fd
440 * is -1, this behaves similarly to create_fence() except that when
441 * rendering is flushed the driver creates a fence fd. Otherwise,
442 * the driver wraps an existing fence fd.
444 * This is used to implement the EGL_ANDROID_native_fence_sync extension.
448 * \param ctx the context associated with the fence
449 * \param fd the fence fd or -1
451 void *(*create_fence_fd
)(__DRIcontext
*ctx
, int fd
);
454 * For fences created with create_fence_fd(), after rendering is flushed,
455 * this retrieves the native fence fd. Caller takes ownership of the
456 * fd and will close() it when it is no longer needed.
460 * \param screen the screen associated with the fence
461 * \param fence the fence
463 int (*get_fence_fd
)(__DRIscreen
*screen
, void *fence
);
468 * Extension for API interop.
469 * See GL/mesa_glinterop.h.
472 #define __DRI2_INTEROP "DRI2_Interop"
473 #define __DRI2_INTEROP_VERSION 1
475 struct mesa_glinterop_device_info
;
476 struct mesa_glinterop_export_in
;
477 struct mesa_glinterop_export_out
;
479 struct __DRI2interopExtensionRec
{
482 /** Same as MesaGLInterop*QueryDeviceInfo. */
483 int (*query_device_info
)(__DRIcontext
*ctx
,
484 struct mesa_glinterop_device_info
*out
);
486 /** Same as MesaGLInterop*ExportObject. */
487 int (*export_object
)(__DRIcontext
*ctx
,
488 struct mesa_glinterop_export_in
*in
,
489 struct mesa_glinterop_export_out
*out
);
494 * Extension for limiting window system back buffer rendering to user-defined
498 #define __DRI2_BUFFER_DAMAGE "DRI2_BufferDamage"
499 #define __DRI2_BUFFER_DAMAGE_VERSION 1
501 struct __DRI2bufferDamageExtensionRec
{
505 * Provides an array of rectangles representing an overriding scissor region
506 * for rendering operations performed to the specified drawable. These
507 * rectangles do not replace client API scissor regions or draw
508 * co-ordinates, but instead inform the driver of the overall bounds of all
509 * operations which will be issued before the next flush.
511 * Any rendering operations writing pixels outside this region to the
512 * drawable will have an undefined effect on the entire drawable.
514 * This entrypoint may only be called after the drawable has either been
515 * newly created or flushed, and before any rendering operations which write
516 * pixels to the drawable. Calling this entrypoint at any other time will
517 * have an undefined effect on the entire drawable.
519 * Calling this entrypoint with @nrects 0 and @rects NULL will reset the
520 * region to the buffer's full size. This entrypoint may be called once to
521 * reset the region, followed by a second call with a populated region,
522 * before a rendering call is made.
524 * Used to implement EGL_KHR_partial_update.
526 * \param drawable affected drawable
527 * \param nrects number of rectangles provided
528 * \param rects the array of rectangles, lower-left origin
530 void (*set_damage_region
)(__DRIdrawable
*drawable
, unsigned int nrects
,
537 * The following extensions describe loader features that the DRI
538 * driver can make use of. Some of these are mandatory, such as the
539 * getDrawableInfo extension for DRI and the DRI Loader extensions for
540 * DRI2, while others are optional, and if present allow the driver to
541 * expose certain features. The loader pass in a NULL terminated
542 * array of these extensions to the driver in the createNewScreen
546 typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension
;
547 typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension
;
548 typedef struct __DRIdamageExtensionRec __DRIdamageExtension
;
549 typedef struct __DRIloaderExtensionRec __DRIloaderExtension
;
550 typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension
;
554 * Callback to getDrawableInfo protocol
556 #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
557 #define __DRI_GET_DRAWABLE_INFO_VERSION 1
558 struct __DRIgetDrawableInfoExtensionRec
{
562 * This function is used to get information about the position, size, and
563 * clip rects of a drawable.
565 GLboolean (* getDrawableInfo
) ( __DRIdrawable
*drawable
,
566 unsigned int * index
, unsigned int * stamp
,
567 int * x
, int * y
, int * width
, int * height
,
568 int * numClipRects
, drm_clip_rect_t
** pClipRects
,
569 int * backX
, int * backY
,
570 int * numBackClipRects
, drm_clip_rect_t
** pBackClipRects
,
571 void *loaderPrivate
);
575 * Callback to get system time for media stream counter extensions.
577 #define __DRI_SYSTEM_TIME "DRI_SystemTime"
578 #define __DRI_SYSTEM_TIME_VERSION 1
579 struct __DRIsystemTimeExtensionRec
{
583 * Get the 64-bit unadjusted system time (UST).
585 int (*getUST
)(int64_t * ust
);
588 * Get the media stream counter (MSC) rate.
590 * Matching the definition in GLX_OML_sync_control, this function returns
591 * the rate of the "media stream counter". In practical terms, this is
592 * the frame refresh rate of the display.
594 GLboolean (*getMSCRate
)(__DRIdrawable
*draw
,
595 int32_t * numerator
, int32_t * denominator
,
596 void *loaderPrivate
);
602 #define __DRI_DAMAGE "DRI_Damage"
603 #define __DRI_DAMAGE_VERSION 1
604 struct __DRIdamageExtensionRec
{
608 * Reports areas of the given drawable which have been modified by the
611 * \param drawable which the drawing was done to.
612 * \param rects rectangles affected, with the drawable origin as the
614 * \param x X offset of the drawable within the screen (used in the
616 * \param y Y offset of the drawable within the screen.
617 * \param front_buffer boolean flag for whether the drawing to the
618 * drawable was actually done directly to the front buffer (instead
619 * of backing storage, for example)
620 * \param loaderPrivate the data passed in at createNewDrawable time
622 void (*reportDamage
)(__DRIdrawable
*draw
,
624 drm_clip_rect_t
*rects
, int num_rects
,
625 GLboolean front_buffer
,
626 void *loaderPrivate
);
629 #define __DRI_SWRAST_IMAGE_OP_DRAW 1
630 #define __DRI_SWRAST_IMAGE_OP_CLEAR 2
631 #define __DRI_SWRAST_IMAGE_OP_SWAP 3
634 * SWRast Loader extension.
636 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
637 #define __DRI_SWRAST_LOADER_VERSION 5
638 struct __DRIswrastLoaderExtensionRec
{
642 * Drawable position and size
644 void (*getDrawableInfo
)(__DRIdrawable
*drawable
,
645 int *x
, int *y
, int *width
, int *height
,
646 void *loaderPrivate
);
649 * Put image to drawable
651 void (*putImage
)(__DRIdrawable
*drawable
, int op
,
652 int x
, int y
, int width
, int height
,
653 char *data
, void *loaderPrivate
);
656 * Get image from readable
658 void (*getImage
)(__DRIdrawable
*readable
,
659 int x
, int y
, int width
, int height
,
660 char *data
, void *loaderPrivate
);
663 * Put image to drawable
667 void (*putImage2
)(__DRIdrawable
*drawable
, int op
,
668 int x
, int y
, int width
, int height
, int stride
,
669 char *data
, void *loaderPrivate
);
672 * Put image to drawable
676 void (*getImage2
)(__DRIdrawable
*readable
,
677 int x
, int y
, int width
, int height
, int stride
,
678 char *data
, void *loaderPrivate
);
681 * Put shm image to drawable
685 void (*putImageShm
)(__DRIdrawable
*drawable
, int op
,
686 int x
, int y
, int width
, int height
, int stride
,
687 int shmid
, char *shmaddr
, unsigned offset
,
688 void *loaderPrivate
);
690 * Get shm image from readable
694 void (*getImageShm
)(__DRIdrawable
*readable
,
695 int x
, int y
, int width
, int height
,
696 int shmid
, void *loaderPrivate
);
699 * Put shm image to drawable (v2)
701 * The original version fixes srcx/y to 0, and expected
702 * the offset to be adjusted. This version allows src x,y
703 * to not be included in the offset. This is needed to
704 * avoid certain overflow checks in the X server, that
705 * result in lost rendering.
709 void (*putImageShm2
)(__DRIdrawable
*drawable
, int op
,
711 int width
, int height
, int stride
,
712 int shmid
, char *shmaddr
, unsigned offset
,
713 void *loaderPrivate
);
717 * Invalidate loader extension. The presence of this extension
718 * indicates to the DRI driver that the loader will call invalidate in
719 * the __DRI2_FLUSH extension, whenever the needs to query for new
720 * buffers. This means that the DRI driver can drop the polling in
723 * The extension doesn't provide any functionality, it's only use to
724 * indicate to the driver that it can use the new semantics. A DRI
725 * driver can use this to switch between the different semantics or
726 * just refuse to initialize if this extension isn't present.
728 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
729 #define __DRI_USE_INVALIDATE_VERSION 1
731 typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension
;
732 struct __DRIuseInvalidateExtensionRec
{
737 * The remaining extensions describe driver extensions, immediately
738 * available interfaces provided by the driver. To start using the
739 * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
740 * the extension you need in the array.
742 #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
745 * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
746 * suffixed by "_drivername", allowing multiple drivers to be built into one
747 * library, and also giving the driver the chance to return a variable driver
748 * extensions struct depending on the driver name being loaded or any other
751 * The function prototype is:
753 * const __DRIextension **__driDriverGetExtensions_drivername(void);
755 #define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
758 * Tokens for __DRIconfig attribs. A number of attributes defined by
759 * GLX or EGL standards are not in the table, as they must be provided
760 * by the loader. For example, FBConfig ID or visual ID, drawable type.
763 #define __DRI_ATTRIB_BUFFER_SIZE 1
764 #define __DRI_ATTRIB_LEVEL 2
765 #define __DRI_ATTRIB_RED_SIZE 3
766 #define __DRI_ATTRIB_GREEN_SIZE 4
767 #define __DRI_ATTRIB_BLUE_SIZE 5
768 #define __DRI_ATTRIB_LUMINANCE_SIZE 6
769 #define __DRI_ATTRIB_ALPHA_SIZE 7
770 #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
771 #define __DRI_ATTRIB_DEPTH_SIZE 9
772 #define __DRI_ATTRIB_STENCIL_SIZE 10
773 #define __DRI_ATTRIB_ACCUM_RED_SIZE 11
774 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
775 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
776 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
777 #define __DRI_ATTRIB_SAMPLE_BUFFERS 15
778 #define __DRI_ATTRIB_SAMPLES 16
779 #define __DRI_ATTRIB_RENDER_TYPE 17
780 #define __DRI_ATTRIB_CONFIG_CAVEAT 18
781 #define __DRI_ATTRIB_CONFORMANT 19
782 #define __DRI_ATTRIB_DOUBLE_BUFFER 20
783 #define __DRI_ATTRIB_STEREO 21
784 #define __DRI_ATTRIB_AUX_BUFFERS 22
785 #define __DRI_ATTRIB_TRANSPARENT_TYPE 23
786 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
787 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
788 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
789 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
790 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
791 #define __DRI_ATTRIB_FLOAT_MODE 29
792 #define __DRI_ATTRIB_RED_MASK 30
793 #define __DRI_ATTRIB_GREEN_MASK 31
794 #define __DRI_ATTRIB_BLUE_MASK 32
795 #define __DRI_ATTRIB_ALPHA_MASK 33
796 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
797 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
798 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
799 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
800 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
801 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
802 #define __DRI_ATTRIB_SWAP_METHOD 40
803 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
804 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
805 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
806 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
807 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
808 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
809 #define __DRI_ATTRIB_YINVERTED 47
810 #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
811 #define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER 49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */
812 #define __DRI_ATTRIB_RED_SHIFT 50
813 #define __DRI_ATTRIB_GREEN_SHIFT 51
814 #define __DRI_ATTRIB_BLUE_SHIFT 52
815 #define __DRI_ATTRIB_ALPHA_SHIFT 53
816 #define __DRI_ATTRIB_MAX 54
818 /* __DRI_ATTRIB_RENDER_TYPE */
819 #define __DRI_ATTRIB_RGBA_BIT 0x01
820 #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
821 #define __DRI_ATTRIB_LUMINANCE_BIT 0x04
822 #define __DRI_ATTRIB_FLOAT_BIT 0x08
823 #define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10
825 /* __DRI_ATTRIB_CONFIG_CAVEAT */
826 #define __DRI_ATTRIB_SLOW_BIT 0x01
827 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
829 /* __DRI_ATTRIB_TRANSPARENT_TYPE */
830 #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
831 #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
833 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
834 #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
835 #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
836 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
838 /* __DRI_ATTRIB_SWAP_METHOD */
839 /* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define
840 * the same tokens as GLX. This is because old and current X servers will
841 * transmit the driconf value grabbed from the AIGLX driver untranslated as
842 * the GLX fbconfig value. __DRI_ATTRIB_SWAP_NONE is only used by dri drivers
843 * to signal to the dri core that the driconfig is single-buffer.
845 #define __DRI_ATTRIB_SWAP_NONE 0x0000
846 #define __DRI_ATTRIB_SWAP_EXCHANGE 0x8061
847 #define __DRI_ATTRIB_SWAP_COPY 0x8062
848 #define __DRI_ATTRIB_SWAP_UNDEFINED 0x8063
851 * This extension defines the core DRI functionality.
853 * Version >= 2 indicates that getConfigAttrib with __DRI_ATTRIB_SWAP_METHOD
854 * returns a reliable value.
856 #define __DRI_CORE "DRI_Core"
857 #define __DRI_CORE_VERSION 2
859 struct __DRIcoreExtensionRec
{
862 __DRIscreen
*(*createNewScreen
)(int screen
, int fd
,
863 unsigned int sarea_handle
,
864 const __DRIextension
**extensions
,
865 const __DRIconfig
***driverConfigs
,
866 void *loaderPrivate
);
868 void (*destroyScreen
)(__DRIscreen
*screen
);
870 const __DRIextension
**(*getExtensions
)(__DRIscreen
*screen
);
872 int (*getConfigAttrib
)(const __DRIconfig
*config
,
874 unsigned int *value
);
876 int (*indexConfigAttrib
)(const __DRIconfig
*config
, int index
,
877 unsigned int *attrib
, unsigned int *value
);
879 __DRIdrawable
*(*createNewDrawable
)(__DRIscreen
*screen
,
880 const __DRIconfig
*config
,
881 unsigned int drawable_id
,
883 void *loaderPrivate
);
885 void (*destroyDrawable
)(__DRIdrawable
*drawable
);
887 void (*swapBuffers
)(__DRIdrawable
*drawable
);
889 __DRIcontext
*(*createNewContext
)(__DRIscreen
*screen
,
890 const __DRIconfig
*config
,
891 __DRIcontext
*shared
,
892 void *loaderPrivate
);
894 int (*copyContext
)(__DRIcontext
*dest
,
898 void (*destroyContext
)(__DRIcontext
*context
);
900 int (*bindContext
)(__DRIcontext
*ctx
,
901 __DRIdrawable
*pdraw
,
902 __DRIdrawable
*pread
);
904 int (*unbindContext
)(__DRIcontext
*ctx
);
908 * Stored version of some component (i.e., server-side DRI module, kernel-side
912 * There are several data structures that explicitly store a major version,
913 * minor version, and patch level. These structures should be modified to
914 * have a \c __DRIversionRec instead.
916 struct __DRIversionRec
{
917 int major
; /**< Major version number. */
918 int minor
; /**< Minor version number. */
919 int patch
; /**< Patch-level. */
923 * Framebuffer information record. Used by libGL to communicate information
924 * about the framebuffer to the driver's \c __driCreateNewScreen function.
926 * In XFree86, most of this information is derrived from data returned by
927 * calling \c XF86DRIGetDeviceInfo.
929 * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
930 * __driUtilCreateNewScreen CallCreateNewScreen
932 * \bug This structure could be better named.
934 struct __DRIframebufferRec
{
935 unsigned char *base
; /**< Framebuffer base address in the CPU's
936 * address space. This value is calculated by
937 * calling \c drmMap on the framebuffer handle
938 * returned by \c XF86DRIGetDeviceInfo (or a
941 int size
; /**< Framebuffer size, in bytes. */
942 int stride
; /**< Number of bytes from one line to the next. */
943 int width
; /**< Pixel width of the framebuffer. */
944 int height
; /**< Pixel height of the framebuffer. */
945 int dev_priv_size
; /**< Size of the driver's dev-priv structure. */
946 void *dev_priv
; /**< Pointer to the driver's dev-priv structure. */
951 * This extension provides alternative screen, drawable and context
952 * constructors for legacy DRI functionality. This is used in
953 * conjunction with the core extension.
955 #define __DRI_LEGACY "DRI_Legacy"
956 #define __DRI_LEGACY_VERSION 1
958 struct __DRIlegacyExtensionRec
{
961 __DRIscreen
*(*createNewScreen
)(int screen
,
962 const __DRIversion
*ddx_version
,
963 const __DRIversion
*dri_version
,
964 const __DRIversion
*drm_version
,
965 const __DRIframebuffer
*frame_buffer
,
966 void *pSAREA
, int fd
,
967 const __DRIextension
**extensions
,
968 const __DRIconfig
***driver_configs
,
969 void *loaderPrivate
);
971 __DRIdrawable
*(*createNewDrawable
)(__DRIscreen
*screen
,
972 const __DRIconfig
*config
,
973 drm_drawable_t hwDrawable
,
974 int renderType
, const int *attrs
,
975 void *loaderPrivate
);
977 __DRIcontext
*(*createNewContext
)(__DRIscreen
*screen
,
978 const __DRIconfig
*config
,
980 __DRIcontext
*shared
,
981 drm_context_t hwContext
,
982 void *loaderPrivate
);
986 * This extension provides alternative screen, drawable and context
987 * constructors for swrast DRI functionality. This is used in
988 * conjunction with the core extension.
990 #define __DRI_SWRAST "DRI_SWRast"
991 #define __DRI_SWRAST_VERSION 4
993 struct __DRIswrastExtensionRec
{
996 __DRIscreen
*(*createNewScreen
)(int screen
,
997 const __DRIextension
**extensions
,
998 const __DRIconfig
***driver_configs
,
999 void *loaderPrivate
);
1001 __DRIdrawable
*(*createNewDrawable
)(__DRIscreen
*screen
,
1002 const __DRIconfig
*config
,
1003 void *loaderPrivate
);
1005 /* Since version 2 */
1006 __DRIcontext
*(*createNewContextForAPI
)(__DRIscreen
*screen
,
1008 const __DRIconfig
*config
,
1009 __DRIcontext
*shared
,
1013 * Create a context for a particular API with a set of attributes
1017 * \sa __DRIdri2ExtensionRec::createContextAttribs
1019 __DRIcontext
*(*createContextAttribs
)(__DRIscreen
*screen
,
1021 const __DRIconfig
*config
,
1022 __DRIcontext
*shared
,
1023 unsigned num_attribs
,
1024 const uint32_t *attribs
,
1026 void *loaderPrivate
);
1029 * createNewScreen() with the driver extensions passed in.
1033 __DRIscreen
*(*createNewScreen2
)(int screen
,
1034 const __DRIextension
**loader_extensions
,
1035 const __DRIextension
**driver_extensions
,
1036 const __DRIconfig
***driver_configs
,
1037 void *loaderPrivate
);
1041 /** Common DRI function definitions, shared among DRI2 and Image extensions
1044 typedef __DRIscreen
*
1045 (*__DRIcreateNewScreen2Func
)(int screen
, int fd
,
1046 const __DRIextension
**extensions
,
1047 const __DRIextension
**driver_extensions
,
1048 const __DRIconfig
***driver_configs
,
1049 void *loaderPrivate
);
1051 typedef __DRIdrawable
*
1052 (*__DRIcreateNewDrawableFunc
)(__DRIscreen
*screen
,
1053 const __DRIconfig
*config
,
1054 void *loaderPrivate
);
1056 typedef __DRIcontext
*
1057 (*__DRIcreateContextAttribsFunc
)(__DRIscreen
*screen
,
1059 const __DRIconfig
*config
,
1060 __DRIcontext
*shared
,
1061 unsigned num_attribs
,
1062 const uint32_t *attribs
,
1064 void *loaderPrivate
);
1066 typedef unsigned int
1067 (*__DRIgetAPIMaskFunc
)(__DRIscreen
*screen
);
1070 * DRI2 Loader extension.
1072 #define __DRI_BUFFER_FRONT_LEFT 0
1073 #define __DRI_BUFFER_BACK_LEFT 1
1074 #define __DRI_BUFFER_FRONT_RIGHT 2
1075 #define __DRI_BUFFER_BACK_RIGHT 3
1076 #define __DRI_BUFFER_DEPTH 4
1077 #define __DRI_BUFFER_STENCIL 5
1078 #define __DRI_BUFFER_ACCUM 6
1079 #define __DRI_BUFFER_FAKE_FRONT_LEFT 7
1080 #define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
1081 #define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
1082 #define __DRI_BUFFER_HIZ 10
1084 /* Inofficial and for internal use. Increase when adding a new buffer token. */
1085 #define __DRI_BUFFER_COUNT 11
1087 struct __DRIbufferRec
{
1088 unsigned int attachment
;
1095 #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
1096 #define __DRI_DRI2_LOADER_VERSION 4
1098 enum dri_loader_cap
{
1099 /* Whether the loader handles RGBA channel ordering correctly. If not,
1100 * only BGRA ordering can be exposed.
1102 DRI_LOADER_CAP_RGBA_ORDERING
,
1103 DRI_LOADER_CAP_FP16
,
1106 struct __DRIdri2LoaderExtensionRec
{
1107 __DRIextension base
;
1109 __DRIbuffer
*(*getBuffers
)(__DRIdrawable
*driDrawable
,
1110 int *width
, int *height
,
1111 unsigned int *attachments
, int count
,
1112 int *out_count
, void *loaderPrivate
);
1115 * Flush pending front-buffer rendering
1117 * Any rendering that has been performed to the
1118 * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
1119 * \c __DRI_BUFFER_FRONT_LEFT.
1121 * \param driDrawable Drawable whose front-buffer is to be flushed
1122 * \param loaderPrivate Loader's private data that was previously passed
1123 * into __DRIdri2ExtensionRec::createNewDrawable
1127 void (*flushFrontBuffer
)(__DRIdrawable
*driDrawable
, void *loaderPrivate
);
1131 * Get list of buffers from the server
1133 * Gets a list of buffer for the specified set of attachments. Unlike
1134 * \c ::getBuffers, this function takes a list of attachments paired with
1135 * opaque \c unsigned \c int value describing the format of the buffer.
1136 * It is the responsibility of the caller to know what the service that
1137 * allocates the buffers will expect to receive for the format.
1139 * \param driDrawable Drawable whose buffers are being queried.
1140 * \param width Output where the width of the buffers is stored.
1141 * \param height Output where the height of the buffers is stored.
1142 * \param attachments List of pairs of attachment ID and opaque format
1143 * requested for the drawable.
1144 * \param count Number of attachment / format pairs stored in
1146 * \param loaderPrivate Loader's private data that was previously passed
1147 * into __DRIdri2ExtensionRec::createNewDrawable.
1151 __DRIbuffer
*(*getBuffersWithFormat
)(__DRIdrawable
*driDrawable
,
1152 int *width
, int *height
,
1153 unsigned int *attachments
, int count
,
1154 int *out_count
, void *loaderPrivate
);
1157 * Return a loader capability value. If the loader doesn't know the enum,
1160 * \param loaderPrivate The last parameter of createNewScreen or
1162 * \param cap See the enum.
1166 unsigned (*getCapability
)(void *loaderPrivate
, enum dri_loader_cap cap
);
1170 * This extension provides alternative screen, drawable and context
1171 * constructors for DRI2.
1173 #define __DRI_DRI2 "DRI_DRI2"
1174 #define __DRI_DRI2_VERSION 4
1176 #define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
1177 #define __DRI_API_GLES 1 /**< OpenGL ES 1.x */
1178 #define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */
1179 #define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
1180 #define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */
1182 #define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
1183 #define __DRI_CTX_ATTRIB_MINOR_VERSION 1
1184 #define __DRI_CTX_ATTRIB_FLAGS 2
1187 * \requires __DRI2_ROBUSTNESS.
1189 #define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
1191 #define __DRI_CTX_FLAG_DEBUG 0x00000001
1192 #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
1195 * \requires __DRI2_ROBUSTNESS.
1197 #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004
1200 * \requires __DRI2_NO_ERROR.
1203 #define __DRI_CTX_FLAG_NO_ERROR 0x00000008
1206 * \name Context reset strategies.
1209 #define __DRI_CTX_RESET_NO_NOTIFICATION 0
1210 #define __DRI_CTX_RESET_LOSE_CONTEXT 1
1213 #define __DRI_CTX_ATTRIB_PRIORITY 4
1215 #define __DRI_CTX_PRIORITY_LOW 0
1216 #define __DRI_CTX_PRIORITY_MEDIUM 1
1217 #define __DRI_CTX_PRIORITY_HIGH 2
1220 * \name Context release behaviors.
1223 #define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR 5
1225 #define __DRI_CTX_RELEASE_BEHAVIOR_NONE 0
1226 #define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH 1
1230 * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
1234 #define __DRI_CTX_ERROR_SUCCESS 0
1236 /** Memory allocation failure */
1237 #define __DRI_CTX_ERROR_NO_MEMORY 1
1239 /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
1240 #define __DRI_CTX_ERROR_BAD_API 2
1242 /** Client requested an API version that the driver can't do. */
1243 #define __DRI_CTX_ERROR_BAD_VERSION 3
1245 /** Client requested a flag or combination of flags the driver can't do. */
1246 #define __DRI_CTX_ERROR_BAD_FLAG 4
1248 /** Client requested an attribute the driver doesn't understand. */
1249 #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
1251 /** Client requested a flag the driver doesn't understand. */
1252 #define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
1255 struct __DRIdri2ExtensionRec
{
1256 __DRIextension base
;
1258 __DRIscreen
*(*createNewScreen
)(int screen
, int fd
,
1259 const __DRIextension
**extensions
,
1260 const __DRIconfig
***driver_configs
,
1261 void *loaderPrivate
);
1263 __DRIcreateNewDrawableFunc createNewDrawable
;
1264 __DRIcontext
*(*createNewContext
)(__DRIscreen
*screen
,
1265 const __DRIconfig
*config
,
1266 __DRIcontext
*shared
,
1267 void *loaderPrivate
);
1269 /* Since version 2 */
1270 __DRIgetAPIMaskFunc getAPIMask
;
1272 __DRIcontext
*(*createNewContextForAPI
)(__DRIscreen
*screen
,
1274 const __DRIconfig
*config
,
1275 __DRIcontext
*shared
,
1278 __DRIbuffer
*(*allocateBuffer
)(__DRIscreen
*screen
,
1279 unsigned int attachment
,
1280 unsigned int format
,
1283 void (*releaseBuffer
)(__DRIscreen
*screen
,
1284 __DRIbuffer
*buffer
);
1287 * Create a context for a particular API with a set of attributes
1291 * \sa __DRIswrastExtensionRec::createContextAttribs
1293 __DRIcreateContextAttribsFunc createContextAttribs
;
1296 * createNewScreen with the driver's extension list passed in.
1300 __DRIcreateNewScreen2Func createNewScreen2
;
1305 * This extension provides functionality to enable various EGLImage
1308 #define __DRI_IMAGE "DRI_IMAGE"
1309 #define __DRI_IMAGE_VERSION 18
1312 * These formats correspond to the similarly named MESA_FORMAT_*
1313 * tokens, except in the native endian of the CPU. For example, on
1314 * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
1315 * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
1317 * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
1318 * by the driver (YUV planar formats) but serve as a base image for
1319 * creating sub-images for the different planes within the image.
1321 * R8, GR88 and NONE should not be used with createImageFromName or
1322 * createImage, and are returned by query from sub images created with
1323 * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
1325 #define __DRI_IMAGE_FORMAT_RGB565 0x1001
1326 #define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
1327 #define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
1328 #define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
1329 #define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
1330 #define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
1331 #define __DRI_IMAGE_FORMAT_GR88 0x1007
1332 #define __DRI_IMAGE_FORMAT_NONE 0x1008
1333 #define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
1334 #define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
1335 #define __DRI_IMAGE_FORMAT_SARGB8 0x100b
1336 #define __DRI_IMAGE_FORMAT_ARGB1555 0x100c
1337 #define __DRI_IMAGE_FORMAT_R16 0x100d
1338 #define __DRI_IMAGE_FORMAT_GR1616 0x100e
1339 #define __DRI_IMAGE_FORMAT_YUYV 0x100f
1340 #define __DRI_IMAGE_FORMAT_XBGR2101010 0x1010
1341 #define __DRI_IMAGE_FORMAT_ABGR2101010 0x1011
1342 #define __DRI_IMAGE_FORMAT_SABGR8 0x1012
1343 #define __DRI_IMAGE_FORMAT_UYVY 0x1013
1344 #define __DRI_IMAGE_FORMAT_XBGR16161616F 0x1014
1345 #define __DRI_IMAGE_FORMAT_ABGR16161616F 0x1015
1347 #define __DRI_IMAGE_USE_SHARE 0x0001
1348 #define __DRI_IMAGE_USE_SCANOUT 0x0002
1349 #define __DRI_IMAGE_USE_CURSOR 0x0004 /* Deprecated */
1350 #define __DRI_IMAGE_USE_LINEAR 0x0008
1351 /* The buffer will only be read by an external process after SwapBuffers,
1352 * in contrary to gbm buffers, front buffers and fake front buffers, which
1353 * could be read after a flush."
1355 #define __DRI_IMAGE_USE_BACKBUFFER 0x0010
1356 /* Whether to expect explicit flushes for external consumers. */
1357 #define __DRI_IMAGE_USE_FLUSH_EXTERNAL 0x0020
1360 #define __DRI_IMAGE_TRANSFER_READ 0x1
1361 #define __DRI_IMAGE_TRANSFER_WRITE 0x2
1362 #define __DRI_IMAGE_TRANSFER_READ_WRITE \
1363 (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)
1366 * Extra fourcc formats used internally to Mesa with createImageFromNames.
1367 * The externally-available fourccs are defined by drm_fourcc.h (DRM_FORMAT_*)
1368 * and WL_DRM_FORMAT_* from wayland_drm.h.
1373 #define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258
1374 #define __DRI_IMAGE_FOURCC_SABGR8888 0x84324258
1377 * Queryable on images created by createImageFromNames.
1379 * RGB and RGBA are may be usable directly as images but its still
1380 * recommended to call fromPlanar with plane == 0.
1382 * Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create
1383 * usable sub-images, sampling from images return raw YUV data and
1384 * color conversion needs to be done in the shader.
1389 #define __DRI_IMAGE_COMPONENTS_RGB 0x3001
1390 #define __DRI_IMAGE_COMPONENTS_RGBA 0x3002
1391 #define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
1392 #define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
1393 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
1394 #define __DRI_IMAGE_COMPONENTS_Y_UXVX 0x3008
1395 #define __DRI_IMAGE_COMPONENTS_AYUV 0x3009
1396 #define __DRI_IMAGE_COMPONENTS_XYUV 0x300A
1397 #define __DRI_IMAGE_COMPONENTS_R 0x3006
1398 #define __DRI_IMAGE_COMPONENTS_RG 0x3007
1402 * queryImage attributes
1405 #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
1406 #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
1407 #define __DRI_IMAGE_ATTRIB_NAME 0x2002
1408 #define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
1409 #define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */
1410 #define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005
1411 #define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */
1412 #define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions
1413 * 7+. Each query will return a
1415 #define __DRI_IMAGE_ATTRIB_FOURCC 0x2008 /* available in versions 11 */
1416 #define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */
1418 #define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
1419 #define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */
1420 #define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */
1422 enum __DRIYUVColorSpace
{
1423 __DRI_YUV_COLOR_SPACE_UNDEFINED
= 0,
1424 __DRI_YUV_COLOR_SPACE_ITU_REC601
= 0x327F,
1425 __DRI_YUV_COLOR_SPACE_ITU_REC709
= 0x3280,
1426 __DRI_YUV_COLOR_SPACE_ITU_REC2020
= 0x3281
1429 enum __DRISampleRange
{
1430 __DRI_YUV_RANGE_UNDEFINED
= 0,
1431 __DRI_YUV_FULL_RANGE
= 0x3282,
1432 __DRI_YUV_NARROW_RANGE
= 0x3283
1435 enum __DRIChromaSiting
{
1436 __DRI_YUV_CHROMA_SITING_UNDEFINED
= 0,
1437 __DRI_YUV_CHROMA_SITING_0
= 0x3284,
1438 __DRI_YUV_CHROMA_SITING_0_5
= 0x3285
1442 * \name Reasons that __DRIimageExtensionRec::createImageFromTexture or
1443 * __DRIimageExtensionRec::createImageFromDmaBufs might fail
1447 #define __DRI_IMAGE_ERROR_SUCCESS 0
1449 /** Memory allocation failure */
1450 #define __DRI_IMAGE_ERROR_BAD_ALLOC 1
1452 /** Client requested an invalid attribute */
1453 #define __DRI_IMAGE_ERROR_BAD_MATCH 2
1455 /** Client requested an invalid texture object */
1456 #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
1458 /** Client requested an invalid pitch and/or offset */
1459 #define __DRI_IMAGE_ERROR_BAD_ACCESS 4
1463 * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
1466 #define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
1473 #define __BLIT_FLAG_FLUSH 0x0001
1474 #define __BLIT_FLAG_FINISH 0x0002
1477 * queryDmaBufFormatModifierAttribs attributes
1480 /* Available in version 16 */
1481 #define __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT 0x0001
1483 typedef struct __DRIimageRec __DRIimage
;
1484 typedef struct __DRIimageExtensionRec __DRIimageExtension
;
1485 struct __DRIimageExtensionRec
{
1486 __DRIextension base
;
1488 __DRIimage
*(*createImageFromName
)(__DRIscreen
*screen
,
1489 int width
, int height
, int format
,
1490 int name
, int pitch
,
1491 void *loaderPrivate
);
1493 /* Deprecated since version 17; see createImageFromRenderbuffer2 */
1494 __DRIimage
*(*createImageFromRenderbuffer
)(__DRIcontext
*context
,
1496 void *loaderPrivate
);
1498 void (*destroyImage
)(__DRIimage
*image
);
1500 __DRIimage
*(*createImage
)(__DRIscreen
*screen
,
1501 int width
, int height
, int format
,
1503 void *loaderPrivate
);
1505 GLboolean (*queryImage
)(__DRIimage
*image
, int attrib
, int *value
);
1508 * The new __DRIimage will share the content with the old one, see dup(2).
1510 __DRIimage
*(*dupImage
)(__DRIimage
*image
, void *loaderPrivate
);
1513 * Validate that a __DRIimage can be used a certain way.
1517 GLboolean (*validateUsage
)(__DRIimage
*image
, unsigned int use
);
1520 * Unlike createImageFromName __DRI_IMAGE_FORMAT is not used but instead
1521 * DRM_FORMAT_*, and strides are in bytes not pixels. Stride is
1522 * also per block and not per pixel (for non-RGB, see gallium blocks).
1526 __DRIimage
*(*createImageFromNames
)(__DRIscreen
*screen
,
1527 int width
, int height
, int fourcc
,
1528 int *names
, int num_names
,
1529 int *strides
, int *offsets
,
1530 void *loaderPrivate
);
1533 * Create an image out of a sub-region of a parent image. This
1534 * entry point lets us create individual __DRIimages for different
1535 * planes in a planar buffer (typically yuv), for example. While a
1536 * sub-image shares the underlying buffer object with the parent
1537 * image and other sibling sub-images, the life times of parent and
1538 * sub-images are not dependent. Destroying the parent or a
1539 * sub-image doesn't affect other images. The underlying buffer
1540 * object is free when no __DRIimage remains that references it.
1542 * Sub-images may overlap, but rendering to overlapping sub-images
1547 __DRIimage
*(*fromPlanar
)(__DRIimage
*image
, int plane
,
1548 void *loaderPrivate
);
1551 * Create image from texture.
1555 __DRIimage
*(*createImageFromTexture
)(__DRIcontext
*context
,
1561 void *loaderPrivate
);
1563 * Like createImageFromNames, but takes a prime fd instead.
1567 __DRIimage
*(*createImageFromFds
)(__DRIscreen
*screen
,
1568 int width
, int height
, int fourcc
,
1569 int *fds
, int num_fds
,
1570 int *strides
, int *offsets
,
1571 void *loaderPrivate
);
1574 * Like createImageFromFds, but takes additional attributes.
1576 * For EGL_EXT_image_dma_buf_import.
1580 __DRIimage
*(*createImageFromDmaBufs
)(__DRIscreen
*screen
,
1581 int width
, int height
, int fourcc
,
1582 int *fds
, int num_fds
,
1583 int *strides
, int *offsets
,
1584 enum __DRIYUVColorSpace color_space
,
1585 enum __DRISampleRange sample_range
,
1586 enum __DRIChromaSiting horiz_siting
,
1587 enum __DRIChromaSiting vert_siting
,
1589 void *loaderPrivate
);
1592 * Blit a part of a __DRIimage to another and flushes
1596 * __BLIT_FLAG_FLUSH: flush after the blit operation
1597 * __BLIT_FLAG_FINISH: flush and wait the blit finished
1601 void (*blitImage
)(__DRIcontext
*context
, __DRIimage
*dst
, __DRIimage
*src
,
1602 int dstx0
, int dsty0
, int dstwidth
, int dstheight
,
1603 int srcx0
, int srcy0
, int srcwidth
, int srcheight
,
1607 * Query for general capabilities of the driver that concern
1608 * buffer sharing and image importing.
1612 int (*getCapabilities
)(__DRIscreen
*screen
);
1615 * Returns a map of the specified region of a __DRIimage for the specified usage.
1617 * flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the
1618 * mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ
1619 * is not included in the flags, the buffer content at map time is
1620 * undefined. Users wanting to modify the mapping must include
1621 * __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not
1622 * included, behaviour when writing the mapping is undefined.
1624 * Returns the byte stride in *stride, and an opaque pointer to data
1625 * tracking the mapping in **data, which must be passed to unmapImage().
1629 void *(*mapImage
)(__DRIcontext
*context
, __DRIimage
*image
,
1630 int x0
, int y0
, int width
, int height
,
1631 unsigned int flags
, int *stride
, void **data
);
1634 * Unmap a previously mapped __DRIimage
1638 void (*unmapImage
)(__DRIcontext
*context
, __DRIimage
*image
, void *data
);
1642 * Creates an image with implementation's favorite modifiers.
1644 * This acts like createImage except there is a list of modifiers passed in
1645 * which the implementation may selectively use to create the DRIimage. The
1646 * result should be the implementation selects one modifier (perhaps it would
1647 * hold on to a few and later pick).
1649 * The created image should be destroyed with destroyImage().
1651 * Returns the new DRIimage. The chosen modifier can be obtained later on
1652 * and passed back to things like the kernel's AddFB2 interface.
1654 * \sa __DRIimageRec::createImage
1658 __DRIimage
*(*createImageWithModifiers
)(__DRIscreen
*screen
,
1659 int width
, int height
, int format
,
1660 const uint64_t *modifiers
,
1661 const unsigned int modifier_count
,
1662 void *loaderPrivate
);
1665 * Like createImageFromDmaBufs, but takes also format modifiers.
1667 * For EGL_EXT_image_dma_buf_import_modifiers.
1671 __DRIimage
*(*createImageFromDmaBufs2
)(__DRIscreen
*screen
,
1672 int width
, int height
, int fourcc
,
1674 int *fds
, int num_fds
,
1675 int *strides
, int *offsets
,
1676 enum __DRIYUVColorSpace color_space
,
1677 enum __DRISampleRange sample_range
,
1678 enum __DRIChromaSiting horiz_siting
,
1679 enum __DRIChromaSiting vert_siting
,
1681 void *loaderPrivate
);
1684 * dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers.
1686 * \param max Maximum number of formats that can be accomodated into
1687 * \param formats. If zero, no formats are returned -
1688 * instead, the driver returns the total number of
1689 * supported dmabuf formats in \param count.
1690 * \param formats Buffer to fill formats into.
1691 * \param count Count of formats returned, or, total number of
1692 * supported formats in case \param max is zero.
1694 * Returns true on success.
1698 GLboolean (*queryDmaBufFormats
)(__DRIscreen
*screen
, int max
,
1699 int *formats
, int *count
);
1702 * dmabuf format modifier query for a given format to support
1703 * EGL_EXT_image_dma_buf_import_modifiers.
1705 * \param fourcc The format to query modifiers for. If this format
1706 * is not supported by the driver, return false.
1707 * \param max Maximum number of modifiers that can be accomodated in
1708 * \param modifiers. If zero, no modifiers are returned -
1709 * instead, the driver returns the total number of
1710 * modifiers for \param format in \param count.
1711 * \param modifiers Buffer to fill modifiers into.
1712 * \param count Count of the modifiers returned, or, total number of
1713 * supported modifiers for \param fourcc in case
1714 * \param max is zero.
1716 * Returns true upon success.
1720 GLboolean (*queryDmaBufModifiers
)(__DRIscreen
*screen
, int fourcc
,
1721 int max
, uint64_t *modifiers
,
1722 unsigned int *external_only
,
1726 * dmabuf format modifier attribute query for a given format and modifier.
1728 * \param fourcc The format to query. If this format is not supported by
1729 * the driver, return false.
1730 * \param modifier The modifier to query. If this format+modifier is not
1731 * supported by the driver, return false.
1732 * \param attrib The __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB to query.
1733 * \param value A pointer to where to store the result of the query.
1735 * Returns true upon success.
1739 GLboolean (*queryDmaBufFormatModifierAttribs
)(__DRIscreen
*screen
,
1740 uint32_t fourcc
, uint64_t modifier
,
1741 int attrib
, uint64_t *value
);
1744 * Create a DRI image from the given renderbuffer.
1746 * \param context the current DRI context
1747 * \param renderbuffer the GL name of the renderbuffer
1748 * \param loaderPrivate for callbacks into the loader related to the image
1749 * \param error will be set to one of __DRI_IMAGE_ERROR_xxx
1750 * \return the newly created image on success, or NULL otherwise
1754 __DRIimage
*(*createImageFromRenderbuffer2
)(__DRIcontext
*context
,
1756 void *loaderPrivate
,
1760 * Flush the image for external consumers. This is called when
1761 * the current context is the producer.
1765 void (*imageFlushExternal
)(__DRIcontext
*context
, __DRIimage
*image
,
1769 * This call indicates that the image has been modified outside of
1770 * the current context. This is called when the current context is
1771 * the consumer of the image.
1775 void (*imageInvalidateExternal
)(__DRIcontext
*context
, __DRIimage
*image
,
1779 * Same as createImageFromName, but also specifies use.
1783 __DRIimage
*(*createImageFromName2
)(__DRIscreen
*screen
,
1784 int width
, int height
, int format
,
1785 int name
, int pitch
, unsigned use
,
1786 void *loaderPrivate
);
1789 * Same as createImageFromDmaBufs, but also specifies modifier and use.
1790 * Set modifier to DRM_FORMAT_MOD_INVALID if not using it.
1794 __DRIimage
*(*createImageFromDmaBufs3
)(__DRIscreen
*screen
,
1795 int width
, int height
, int fourcc
,
1796 uint64_t modifier
, unsigned use
,
1797 int *fds
, int num_fds
,
1798 int *strides
, int *offsets
,
1799 enum __DRIYUVColorSpace color_space
,
1800 enum __DRISampleRange sample_range
,
1801 enum __DRIChromaSiting horiz_siting
,
1802 enum __DRIChromaSiting vert_siting
,
1804 void *loaderPrivate
);
1809 * This extension must be implemented by the loader and passed to the
1810 * driver at screen creation time. The EGLImage entry points in the
1811 * various client APIs take opaque EGLImage handles and use this
1812 * extension to map them to a __DRIimage. At version 1, this
1813 * extensions allows mapping EGLImage pointers to __DRIimage pointers,
1814 * but future versions could support other EGLImage-like, opaque types
1815 * with new lookup functions.
1817 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
1818 #define __DRI_IMAGE_LOOKUP_VERSION 1
1820 typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension
;
1821 struct __DRIimageLookupExtensionRec
{
1822 __DRIextension base
;
1824 __DRIimage
*(*lookupEGLImage
)(__DRIscreen
*screen
, void *image
,
1825 void *loaderPrivate
);
1829 * This extension allows for common DRI2 options
1831 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
1832 #define __DRI2_CONFIG_QUERY_VERSION 1
1834 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension
;
1835 struct __DRI2configQueryExtensionRec
{
1836 __DRIextension base
;
1838 int (*configQueryb
)(__DRIscreen
*screen
, const char *var
, unsigned char *val
);
1839 int (*configQueryi
)(__DRIscreen
*screen
, const char *var
, int *val
);
1840 int (*configQueryf
)(__DRIscreen
*screen
, const char *var
, float *val
);
1844 * Robust context driver extension.
1846 * Existence of this extension means the driver can accept the
1847 * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
1848 * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
1849 * \c __DRIdri2ExtensionRec::createContextAttribs.
1851 #define __DRI2_ROBUSTNESS "DRI_Robustness"
1852 #define __DRI2_ROBUSTNESS_VERSION 1
1854 typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension
;
1855 struct __DRIrobustnessExtensionRec
{
1856 __DRIextension base
;
1860 * No-error context driver extension.
1862 * Existence of this extension means the driver can accept the
1863 * __DRI_CTX_FLAG_NO_ERROR flag.
1865 #define __DRI2_NO_ERROR "DRI_NoError"
1866 #define __DRI2_NO_ERROR_VERSION 1
1868 typedef struct __DRInoErrorExtensionRec
{
1869 __DRIextension base
;
1870 } __DRInoErrorExtension
;
1873 * Flush control driver extension.
1875 * Existence of this extension means the driver can accept the
1876 * \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in
1877 * \c __DRIdri2ExtensionRec::createContextAttribs.
1879 #define __DRI2_FLUSH_CONTROL "DRI_FlushControl"
1880 #define __DRI2_FLUSH_CONTROL_VERSION 1
1882 typedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension
;
1883 struct __DRI2flushControlExtensionRec
{
1884 __DRIextension base
;
1888 * DRI config options extension.
1890 * This extension provides the XML string containing driver options for use by
1891 * the loader in supporting the driconf application.
1894 * - Add the getXml getter function which allows the driver more flexibility in
1895 * how the XML is provided.
1896 * - Deprecate the direct xml pointer. It is only provided as a fallback for
1897 * older versions of libGL and must not be used by clients that are aware of
1898 * the newer version. Future driver versions may set it to NULL.
1900 #define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
1901 #define __DRI_CONFIG_OPTIONS_VERSION 2
1903 typedef struct __DRIconfigOptionsExtensionRec
{
1904 __DRIextension base
;
1905 const char *xml
; /**< deprecated since v2, use getXml instead */
1908 * Get an XML string that describes available driver options for use by a
1909 * config application.
1911 * The returned string must be heap-allocated. The caller is responsible for
1914 char *(*getXml
)(const char *driver_name
);
1915 } __DRIconfigOptionsExtension
;
1918 * This extension provides a driver vtable to a set of common driver helper
1919 * functions (driCoreExtension, driDRI2Extension) within the driver
1920 * implementation, as opposed to having to pass them through a global
1923 * It is not intended to be public API to the actual loader, and the vtable
1924 * layout may change at any time.
1926 #define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
1927 #define __DRI_DRIVER_VTABLE_VERSION 1
1929 typedef struct __DRIDriverVtableExtensionRec
{
1930 __DRIextension base
;
1931 const struct __DriverAPIRec
*vtable
;
1932 } __DRIDriverVtableExtension
;
1935 * Query renderer driver extension
1937 * This allows the window system layer (either EGL or GLX) to query aspects of
1938 * hardware and driver support without creating a context.
1940 #define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
1941 #define __DRI2_RENDERER_QUERY_VERSION 1
1943 #define __DRI2_RENDERER_VENDOR_ID 0x0000
1944 #define __DRI2_RENDERER_DEVICE_ID 0x0001
1945 #define __DRI2_RENDERER_VERSION 0x0002
1946 #define __DRI2_RENDERER_ACCELERATED 0x0003
1947 #define __DRI2_RENDERER_VIDEO_MEMORY 0x0004
1948 #define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005
1949 #define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006
1950 #define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007
1951 #define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008
1952 #define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009
1953 #define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a
1954 #define __DRI2_RENDERER_HAS_TEXTURE_3D 0x000b
1955 /* Whether there is an sRGB format support for every supported 32-bit UNORM
1958 #define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c
1960 /* Bitmaks of supported/available context priorities - must match
1961 * __EGL_CONTEXT_PRIORITY_LOW_BIT et al
1963 #define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY 0x000d
1964 #define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW (1 << 0)
1965 #define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1)
1966 #define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2)
1968 typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension
;
1969 struct __DRI2rendererQueryExtensionRec
{
1970 __DRIextension base
;
1972 int (*queryInteger
)(__DRIscreen
*screen
, int attribute
, unsigned int *val
);
1973 int (*queryString
)(__DRIscreen
*screen
, int attribute
, const char **val
);
1977 * Image Loader extension. Drivers use this to allocate color buffers
1981 * See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask.
1983 enum __DRIimageBufferMask
{
1984 __DRI_IMAGE_BUFFER_BACK
= (1 << 0),
1985 __DRI_IMAGE_BUFFER_FRONT
= (1 << 1),
1988 * A buffer shared between application and compositor. The buffer may be
1989 * simultaneously accessed by each.
1991 * A shared buffer is equivalent to an EGLSurface whose EGLConfig contains
1992 * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as
1993 * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
1994 * EGL_SINGLE_BUFFER.
1996 * If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no
1997 * other bits. As a corollary, a __DRIdrawable that has a "shared" buffer
1998 * has no front nor back buffer.
2000 * The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only
2002 * - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER.
2003 * - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER.
2004 * - The EGLConfig of the drawable EGLSurface contains
2005 * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.
2006 * - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER.
2007 * Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as
2008 * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
2009 * EGL_SINGLE_BUFFER. (See the EGL 1.5 and
2010 * EGL_KHR_mutable_render_buffer spec for details about "pending" vs
2011 * "active" EGL_RENDER_BUFFER state).
2013 * A shared buffer is similar to a front buffer in that all rendering to the
2014 * buffer should appear promptly on the screen. It is different from
2015 * a front buffer in that its behavior is independent from the
2016 * GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the
2017 * __DRIdrawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all
2018 * rendering should appear promptly on the screen if GL_DRAW_BUFFER is not
2021 * The difference between a shared buffer and a front buffer is motivated
2022 * by the constraints of Android and OpenGL ES. OpenGL ES does not support
2023 * front-buffer rendering. Android's SurfaceFlinger protocol provides the
2024 * EGL driver only a back buffer and no front buffer. The shared buffer
2025 * mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though
2026 * EGL that allows Android OpenGL ES applications to render to what is
2027 * effectively the front buffer, a backdoor that required no change to the
2028 * OpenGL ES API and little change to the SurfaceFlinger API.
2030 __DRI_IMAGE_BUFFER_SHARED
= (1 << 2),
2033 struct __DRIimageList
{
2034 uint32_t image_mask
;
2039 #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
2040 #define __DRI_IMAGE_LOADER_VERSION 3
2042 struct __DRIimageLoaderExtensionRec
{
2043 __DRIextension base
;
2046 * Allocate color buffers.
2048 * \param driDrawable
2049 * \param width Width of allocated buffers
2050 * \param height Height of allocated buffers
2051 * \param format one of __DRI_IMAGE_FORMAT_*
2052 * \param stamp Address of variable to be updated when
2053 * getBuffers must be called again
2054 * \param loaderPrivate The loaderPrivate for driDrawable
2055 * \param buffer_mask Set of buffers to allocate. A bitmask of
2056 * __DRIimageBufferMask.
2057 * \param buffers Returned buffers
2059 int (*getBuffers
)(__DRIdrawable
*driDrawable
,
2060 unsigned int format
,
2062 void *loaderPrivate
,
2063 uint32_t buffer_mask
,
2064 struct __DRIimageList
*buffers
);
2067 * Flush pending front-buffer rendering
2069 * Any rendering that has been performed to the
2070 * fake front will be flushed to the front
2072 * \param driDrawable Drawable whose front-buffer is to be flushed
2073 * \param loaderPrivate Loader's private data that was previously passed
2074 * into __DRIdri2ExtensionRec::createNewDrawable
2076 void (*flushFrontBuffer
)(__DRIdrawable
*driDrawable
, void *loaderPrivate
);
2079 * Return a loader capability value. If the loader doesn't know the enum,
2084 unsigned (*getCapability
)(void *loaderPrivate
, enum dri_loader_cap cap
);
2087 * Flush swap buffers
2089 * Make sure any outstanding swap buffers have been submitted to the
2092 * \param driDrawable Drawable whose swaps need to be flushed
2093 * \param loaderPrivate Loader's private data that was previously passed
2094 * into __DRIdri2ExtensionRec::createNewDrawable
2098 void (*flushSwapBuffers
)(__DRIdrawable
*driDrawable
, void *loaderPrivate
);
2105 #define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"
2106 #define __DRI_IMAGE_DRIVER_VERSION 1
2108 struct __DRIimageDriverExtensionRec
{
2109 __DRIextension base
;
2111 /* Common DRI functions, shared with DRI2 */
2112 __DRIcreateNewScreen2Func createNewScreen2
;
2113 __DRIcreateNewDrawableFunc createNewDrawable
;
2114 __DRIcreateContextAttribsFunc createContextAttribs
;
2115 __DRIgetAPIMaskFunc getAPIMask
;
2119 * Background callable loader extension.
2121 * Loaders expose this extension to indicate to drivers that they are capable
2122 * of handling callbacks from the driver's background drawing threads.
2124 #define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"
2125 #define __DRI_BACKGROUND_CALLABLE_VERSION 1
2127 typedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension
;
2128 struct __DRIbackgroundCallableExtensionRec
{
2129 __DRIextension base
;
2132 * Indicate that this thread is being used by the driver as a background
2133 * drawing thread which may make callbacks to the loader.
2135 * \param loaderPrivate is the value that was passed to to the driver when
2136 * the context was created. This can be used by the loader to identify
2137 * which context any callbacks are associated with.
2139 * If this function is called more than once from any given thread, each
2140 * subsequent call overrides the loaderPrivate data that was passed in the
2141 * previous call. The driver can take advantage of this to re-use a
2142 * background thread to perform drawing on behalf of multiple contexts.
2144 * It is permissible for the driver to call this function from a
2145 * non-background thread (i.e. a thread that has already been bound to a
2146 * context using __DRIcoreExtensionRec::bindContext()); when this happens,
2147 * the \c loaderPrivate pointer must be equal to the pointer that was
2148 * passed to the driver when the currently bound context was created.
2150 * This call should execute quickly enough that the driver can call it with
2151 * impunity whenever a background thread starts performing drawing
2152 * operations (e.g. it should just set a thread-local variable).
2154 void (*setBackgroundContext
)(void *loaderPrivate
);
2157 * Indicate that it is multithread safe to use glthread. For GLX/EGL
2158 * platforms using Xlib, that involves calling XInitThreads, before
2159 * opening an X display.
2161 * Note: only supported if extension version is at least 2.
2163 * \param loaderPrivate is the value that was passed to to the driver when
2164 * the context was created. This can be used by the loader to identify
2165 * which context any callbacks are associated with.
2167 GLboolean (*isThreadSafe
)(void *loaderPrivate
);
2171 * The driver portion of EGL_KHR_mutable_render_buffer.
2173 * If the driver creates a __DRIconfig with
2174 * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension.
2176 * To support this extension:
2178 * - The driver should create at least one __DRIconfig with
2179 * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but
2182 * - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if
2183 * returned by __DRIimageLoaderExtension:getBuffers().
2185 * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call
2186 * __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() in
2187 * response to glFlush and glFinish. (This requirement is not documented
2188 * in EGL_KHR_mutable_render_buffer, but is a de-facto requirement in the
2189 * Android ecosystem. Android applications expect that glFlush will
2190 * immediately display the buffer when in shared buffer mode, and Android
2191 * drivers comply with this expectation). It :may: call
2192 * displaySharedBuffer() more often than required.
2194 * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the
2195 * buffer is always in a format compatible for display because the
2196 * display engine (usually SurfaceFlinger or hwcomposer) may display the
2197 * image at any time, even concurrently with 3D rendering. For example,
2198 * display hardware and the GL hardware may be able to access the buffer
2199 * simultaneously. In particular, if the buffer is compressed then take
2200 * care that SurfaceFlinger and hwcomposer can consume the compression
2203 * \see __DRI_IMAGE_BUFFER_SHARED
2204 * \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER
2205 * \see __DRI_MUTABLE_RENDER_BUFFER_LOADER
2207 #define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver"
2208 #define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 1
2210 typedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension
;
2211 struct __DRImutableRenderBufferDriverExtensionRec
{
2212 __DRIextension base
;
2216 * The loader portion of EGL_KHR_mutable_render_buffer.
2218 * Requires loader extension DRI_IMAGE_LOADER, through which the loader sends
2219 * __DRI_IMAGE_BUFFER_SHARED to the driver.
2221 * \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER
2223 #define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader"
2224 #define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 1
2226 typedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension
;
2227 struct __DRImutableRenderBufferLoaderExtensionRec
{
2228 __DRIextension base
;
2231 * Inform the display engine (that is, SurfaceFlinger and/or hwcomposer)
2232 * that the __DRIdrawable has new content.
2234 * The display engine may ignore this call, for example, if it continually
2235 * refreshes and displays the buffer on every frame, as in
2236 * EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display
2237 * engine may refresh and display the buffer only in frames in which the
2238 * driver calls this.
2240 * If the fence_fd is not -1, then the display engine will display the
2241 * buffer only after the fence signals.
2243 * The drawable's current __DRIimageBufferMask, as returned by
2244 * __DRIimageLoaderExtension::getBuffers(), must be
2245 * __DRI_IMAGE_BUFFER_SHARED.
2247 void (*displaySharedBuffer
)(__DRIdrawable
*drawable
, int fence_fd
,
2248 void *loaderPrivate
);