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
43 /* For archs with no drm.h */
44 #if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__)
45 #ifndef __NOT_HAVE_DRM_H
46 #define __NOT_HAVE_DRM_H
50 #ifndef __NOT_HAVE_DRM_H
53 typedef unsigned int drm_context_t
;
54 typedef unsigned int drm_drawable_t
;
55 typedef struct drm_clip_rect drm_clip_rect_t
;
59 * \name DRI interface structures
61 * The following structures define the interface between the GLX client
62 * side library and the DRI (direct rendering infrastructure).
65 typedef struct __DRIdisplayRec __DRIdisplay
;
66 typedef struct __DRIscreenRec __DRIscreen
;
67 typedef struct __DRIcontextRec __DRIcontext
;
68 typedef struct __DRIdrawableRec __DRIdrawable
;
69 typedef struct __DRIconfigRec __DRIconfig
;
70 typedef struct __DRIframebufferRec __DRIframebuffer
;
71 typedef struct __DRIversionRec __DRIversion
;
73 typedef struct __DRIcoreExtensionRec __DRIcoreExtension
;
74 typedef struct __DRIextensionRec __DRIextension
;
75 typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension
;
76 typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension
;
77 typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension
;
78 typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension
;
79 typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension
;
80 typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension
;
81 typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension
;
82 typedef struct __DRIswrastExtensionRec __DRIswrastExtension
;
83 typedef struct __DRIbufferRec __DRIbuffer
;
84 typedef struct __DRIdri2ExtensionRec __DRIdri2Extension
;
85 typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension
;
86 typedef struct __DRI2flushExtensionRec __DRI2flushExtension
;
87 typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension
;
93 * Extension struct. Drivers 'inherit' from this struct by embedding
94 * it as the first element in the extension struct.
96 * We never break API in for a DRI extension. If we need to change
97 * the way things work in a non-backwards compatible manner, we
98 * introduce a new extension. During a transition period, we can
99 * leave both the old and the new extension in the driver, which
100 * allows us to move to the new interface without having to update the
101 * loader(s) in lock step.
103 * However, we can add entry points to an extension over time as long
104 * as we don't break the old ones. As we add entry points to an
105 * extension, we increase the version number. The corresponding
106 * #define can be used to guard code that accesses the new entry
107 * points at compile time and the version field in the extension
108 * struct can be used at run-time to determine how to use the
111 struct __DRIextensionRec
{
117 * The first set of extension are the screen extensions, returned by
118 * __DRIcore::getExtensions(). This entry point will return a list of
119 * extensions and the loader can use the ones it knows about by
120 * casting them to more specific extensions and advertising any GLX
121 * extensions the DRI extensions enables.
125 * Used by drivers to indicate support for setting the read drawable.
127 #define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
128 #define __DRI_READ_DRAWABLE_VERSION 1
131 * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
133 #define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
134 #define __DRI_COPY_SUB_BUFFER_VERSION 1
135 struct __DRIcopySubBufferExtensionRec
{
137 void (*copySubBuffer
)(__DRIdrawable
*drawable
, int x
, int y
, int w
, int h
);
141 * Used by drivers that implement the GLX_SGI_swap_control or
142 * GLX_MESA_swap_control extension.
144 #define __DRI_SWAP_CONTROL "DRI_SwapControl"
145 #define __DRI_SWAP_CONTROL_VERSION 1
146 struct __DRIswapControlExtensionRec
{
148 void (*setSwapInterval
)(__DRIdrawable
*drawable
, unsigned int inteval
);
149 unsigned int (*getSwapInterval
)(__DRIdrawable
*drawable
);
153 * Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
155 #define __DRI_FRAME_TRACKING "DRI_FrameTracking"
156 #define __DRI_FRAME_TRACKING_VERSION 1
157 struct __DRIframeTrackingExtensionRec
{
161 * Enable or disable frame usage tracking.
163 * \since Internal API version 20030317.
165 int (*frameTracking
)(__DRIdrawable
*drawable
, GLboolean enable
);
168 * Retrieve frame usage information.
170 * \since Internal API version 20030317.
172 int (*queryFrameTracking
)(__DRIdrawable
*drawable
,
173 int64_t * sbc
, int64_t * missedFrames
,
174 float * lastMissedUsage
, float * usage
);
179 * Used by drivers that implement the GLX_SGI_video_sync extension.
181 #define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
182 #define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
183 struct __DRImediaStreamCounterExtensionRec
{
187 * Wait for the MSC to equal target_msc, or, if that has already passed,
188 * the next time (MSC % divisor) is equal to remainder. If divisor is
189 * zero, the function will return as soon as MSC is greater than or equal
192 int (*waitForMSC
)(__DRIdrawable
*drawable
,
193 int64_t target_msc
, int64_t divisor
, int64_t remainder
,
194 int64_t * msc
, int64_t * sbc
);
197 * Get the number of vertical refreshes since some point in time before
198 * this function was first called (i.e., system start up).
200 int (*getDrawableMSC
)(__DRIscreen
*screen
, __DRIdrawable
*drawable
,
205 #define __DRI_TEX_OFFSET "DRI_TexOffset"
206 #define __DRI_TEX_OFFSET_VERSION 1
207 struct __DRItexOffsetExtensionRec
{
211 * Method to override base texture image with a driver specific 'offset'.
212 * The depth passed in allows e.g. to ignore the alpha channel of texture
213 * images where the non-alpha components don't occupy a whole texel.
215 * For GLX_EXT_texture_from_pixmap with AIGLX.
217 void (*setTexOffset
)(__DRIcontext
*pDRICtx
, GLint texname
,
218 unsigned long long offset
, GLint depth
, GLuint pitch
);
222 /* Valid values for format in the setTexBuffer2 function below. These
223 * values match the GLX tokens for compatibility reasons, but we
224 * define them here since the DRI interface can't depend on GLX. */
225 #define __DRI_TEXTURE_FORMAT_NONE 0x20D8
226 #define __DRI_TEXTURE_FORMAT_RGB 0x20D9
227 #define __DRI_TEXTURE_FORMAT_RGBA 0x20DA
229 #define __DRI_TEX_BUFFER "DRI_TexBuffer"
230 #define __DRI_TEX_BUFFER_VERSION 2
231 struct __DRItexBufferExtensionRec
{
235 * Method to override base texture image with the contents of a
238 * For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of
239 * setTexBuffer2 in version 2 of this interface
241 void (*setTexBuffer
)(__DRIcontext
*pDRICtx
,
243 __DRIdrawable
*pDraw
);
246 * Method to override base texture image with the contents of a
247 * __DRIdrawable, including the required texture format attribute.
249 * For GLX_EXT_texture_from_pixmap with AIGLX.
251 void (*setTexBuffer2
)(__DRIcontext
*pDRICtx
,
254 __DRIdrawable
*pDraw
);
256 * Method to release texture buffer in case some special platform
259 * For GLX_EXT_texture_from_pixmap with AIGLX.
261 void (*releaseTexBuffer
)(__DRIcontext
*pDRICtx
,
263 __DRIdrawable
*pDraw
);
267 * Used by drivers that implement DRI2
269 #define __DRI2_FLUSH "DRI2_Flush"
270 #define __DRI2_FLUSH_VERSION 4
272 #define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
273 #define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */
275 enum __DRI2throttleReason
{
276 __DRI2_THROTTLE_SWAPBUFFER
,
277 __DRI2_THROTTLE_COPYSUBBUFFER
,
278 __DRI2_THROTTLE_FLUSHFRONT
281 struct __DRI2flushExtensionRec
{
283 void (*flush
)(__DRIdrawable
*drawable
);
286 * Ask the driver to call getBuffers/getBuffersWithFormat before
287 * it starts rendering again.
289 * \param drawable the drawable to invalidate
293 void (*invalidate
)(__DRIdrawable
*drawable
);
296 * This function reduces the number of flushes in the driver by combining
297 * several operations into one call.
304 * \param context the context
305 * \param drawable the drawable to flush
306 * \param flags a combination of _DRI2_FLUSH_xxx flags
307 * \param throttle_reason the reason for throttling, 0 = no throttling
311 void (*flush_with_flags
)(__DRIcontext
*ctx
,
312 __DRIdrawable
*drawable
,
314 enum __DRI2throttleReason throttle_reason
);
319 * Extension that the driver uses to request
320 * throttle callbacks.
323 #define __DRI2_THROTTLE "DRI2_Throttle"
324 #define __DRI2_THROTTLE_VERSION 1
326 struct __DRI2throttleExtensionRec
{
328 void (*throttle
)(__DRIcontext
*ctx
,
329 __DRIdrawable
*drawable
,
330 enum __DRI2throttleReason reason
);
336 * The following extensions describe loader features that the DRI
337 * driver can make use of. Some of these are mandatory, such as the
338 * getDrawableInfo extension for DRI and the DRI Loader extensions for
339 * DRI2, while others are optional, and if present allow the driver to
340 * expose certain features. The loader pass in a NULL terminated
341 * array of these extensions to the driver in the createNewScreen
345 typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension
;
346 typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension
;
347 typedef struct __DRIdamageExtensionRec __DRIdamageExtension
;
348 typedef struct __DRIloaderExtensionRec __DRIloaderExtension
;
349 typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension
;
353 * Callback to getDrawableInfo protocol
355 #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
356 #define __DRI_GET_DRAWABLE_INFO_VERSION 1
357 struct __DRIgetDrawableInfoExtensionRec
{
361 * This function is used to get information about the position, size, and
362 * clip rects of a drawable.
364 GLboolean (* getDrawableInfo
) ( __DRIdrawable
*drawable
,
365 unsigned int * index
, unsigned int * stamp
,
366 int * x
, int * y
, int * width
, int * height
,
367 int * numClipRects
, drm_clip_rect_t
** pClipRects
,
368 int * backX
, int * backY
,
369 int * numBackClipRects
, drm_clip_rect_t
** pBackClipRects
,
370 void *loaderPrivate
);
374 * Callback to get system time for media stream counter extensions.
376 #define __DRI_SYSTEM_TIME "DRI_SystemTime"
377 #define __DRI_SYSTEM_TIME_VERSION 1
378 struct __DRIsystemTimeExtensionRec
{
382 * Get the 64-bit unadjusted system time (UST).
384 int (*getUST
)(int64_t * ust
);
387 * Get the media stream counter (MSC) rate.
389 * Matching the definition in GLX_OML_sync_control, this function returns
390 * the rate of the "media stream counter". In practical terms, this is
391 * the frame refresh rate of the display.
393 GLboolean (*getMSCRate
)(__DRIdrawable
*draw
,
394 int32_t * numerator
, int32_t * denominator
,
395 void *loaderPrivate
);
401 #define __DRI_DAMAGE "DRI_Damage"
402 #define __DRI_DAMAGE_VERSION 1
403 struct __DRIdamageExtensionRec
{
407 * Reports areas of the given drawable which have been modified by the
410 * \param drawable which the drawing was done to.
411 * \param rects rectangles affected, with the drawable origin as the
413 * \param x X offset of the drawable within the screen (used in the
415 * \param y Y offset of the drawable within the screen.
416 * \param front_buffer boolean flag for whether the drawing to the
417 * drawable was actually done directly to the front buffer (instead
418 * of backing storage, for example)
419 * \param loaderPrivate the data passed in at createNewDrawable time
421 void (*reportDamage
)(__DRIdrawable
*draw
,
423 drm_clip_rect_t
*rects
, int num_rects
,
424 GLboolean front_buffer
,
425 void *loaderPrivate
);
428 #define __DRI_SWRAST_IMAGE_OP_DRAW 1
429 #define __DRI_SWRAST_IMAGE_OP_CLEAR 2
430 #define __DRI_SWRAST_IMAGE_OP_SWAP 3
433 * SWRast Loader extension.
435 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
436 #define __DRI_SWRAST_LOADER_VERSION 1
437 struct __DRIswrastLoaderExtensionRec
{
441 * Drawable position and size
443 void (*getDrawableInfo
)(__DRIdrawable
*drawable
,
444 int *x
, int *y
, int *width
, int *height
,
445 void *loaderPrivate
);
448 * Put image to drawable
450 void (*putImage
)(__DRIdrawable
*drawable
, int op
,
451 int x
, int y
, int width
, int height
,
452 char *data
, void *loaderPrivate
);
455 * Get image from readable
457 void (*getImage
)(__DRIdrawable
*readable
,
458 int x
, int y
, int width
, int height
,
459 char *data
, void *loaderPrivate
);
463 * Invalidate loader extension. The presence of this extension
464 * indicates to the DRI driver that the loader will call invalidate in
465 * the __DRI2_FLUSH extension, whenever the needs to query for new
466 * buffers. This means that the DRI driver can drop the polling in
469 * The extension doesn't provide any functionality, it's only use to
470 * indicate to the driver that it can use the new semantics. A DRI
471 * driver can use this to switch between the different semantics or
472 * just refuse to initialize if this extension isn't present.
474 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
475 #define __DRI_USE_INVALIDATE_VERSION 1
477 typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension
;
478 struct __DRIuseInvalidateExtensionRec
{
483 * The remaining extensions describe driver extensions, immediately
484 * available interfaces provided by the driver. To start using the
485 * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
486 * the extension you need in the array.
488 #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
491 * Tokens for __DRIconfig attribs. A number of attributes defined by
492 * GLX or EGL standards are not in the table, as they must be provided
493 * by the loader. For example, FBConfig ID or visual ID, drawable type.
496 #define __DRI_ATTRIB_BUFFER_SIZE 1
497 #define __DRI_ATTRIB_LEVEL 2
498 #define __DRI_ATTRIB_RED_SIZE 3
499 #define __DRI_ATTRIB_GREEN_SIZE 4
500 #define __DRI_ATTRIB_BLUE_SIZE 5
501 #define __DRI_ATTRIB_LUMINANCE_SIZE 6
502 #define __DRI_ATTRIB_ALPHA_SIZE 7
503 #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
504 #define __DRI_ATTRIB_DEPTH_SIZE 9
505 #define __DRI_ATTRIB_STENCIL_SIZE 10
506 #define __DRI_ATTRIB_ACCUM_RED_SIZE 11
507 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
508 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
509 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
510 #define __DRI_ATTRIB_SAMPLE_BUFFERS 15
511 #define __DRI_ATTRIB_SAMPLES 16
512 #define __DRI_ATTRIB_RENDER_TYPE 17
513 #define __DRI_ATTRIB_CONFIG_CAVEAT 18
514 #define __DRI_ATTRIB_CONFORMANT 19
515 #define __DRI_ATTRIB_DOUBLE_BUFFER 20
516 #define __DRI_ATTRIB_STEREO 21
517 #define __DRI_ATTRIB_AUX_BUFFERS 22
518 #define __DRI_ATTRIB_TRANSPARENT_TYPE 23
519 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
520 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
521 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
522 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
523 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
524 #define __DRI_ATTRIB_FLOAT_MODE 29
525 #define __DRI_ATTRIB_RED_MASK 30
526 #define __DRI_ATTRIB_GREEN_MASK 31
527 #define __DRI_ATTRIB_BLUE_MASK 32
528 #define __DRI_ATTRIB_ALPHA_MASK 33
529 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
530 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
531 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
532 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
533 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
534 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
535 #define __DRI_ATTRIB_SWAP_METHOD 40
536 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
537 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
538 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
539 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
540 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
541 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
542 #define __DRI_ATTRIB_YINVERTED 47
543 #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
545 /* __DRI_ATTRIB_RENDER_TYPE */
546 #define __DRI_ATTRIB_RGBA_BIT 0x01
547 #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
548 #define __DRI_ATTRIB_LUMINANCE_BIT 0x04
549 #define __DRI_ATTRIB_FLOAT_BIT 0x08
550 #define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10
552 /* __DRI_ATTRIB_CONFIG_CAVEAT */
553 #define __DRI_ATTRIB_SLOW_BIT 0x01
554 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
556 /* __DRI_ATTRIB_TRANSPARENT_TYPE */
557 #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
558 #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
560 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
561 #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
562 #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
563 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
566 * This extension defines the core DRI functionality.
568 #define __DRI_CORE "DRI_Core"
569 #define __DRI_CORE_VERSION 1
571 struct __DRIcoreExtensionRec
{
574 __DRIscreen
*(*createNewScreen
)(int screen
, int fd
,
575 unsigned int sarea_handle
,
576 const __DRIextension
**extensions
,
577 const __DRIconfig
***driverConfigs
,
578 void *loaderPrivate
);
580 void (*destroyScreen
)(__DRIscreen
*screen
);
582 const __DRIextension
**(*getExtensions
)(__DRIscreen
*screen
);
584 int (*getConfigAttrib
)(const __DRIconfig
*config
,
586 unsigned int *value
);
588 int (*indexConfigAttrib
)(const __DRIconfig
*config
, int index
,
589 unsigned int *attrib
, unsigned int *value
);
591 __DRIdrawable
*(*createNewDrawable
)(__DRIscreen
*screen
,
592 const __DRIconfig
*config
,
593 unsigned int drawable_id
,
595 void *loaderPrivate
);
597 void (*destroyDrawable
)(__DRIdrawable
*drawable
);
599 void (*swapBuffers
)(__DRIdrawable
*drawable
);
601 __DRIcontext
*(*createNewContext
)(__DRIscreen
*screen
,
602 const __DRIconfig
*config
,
603 __DRIcontext
*shared
,
604 void *loaderPrivate
);
606 int (*copyContext
)(__DRIcontext
*dest
,
610 void (*destroyContext
)(__DRIcontext
*context
);
612 int (*bindContext
)(__DRIcontext
*ctx
,
613 __DRIdrawable
*pdraw
,
614 __DRIdrawable
*pread
);
616 int (*unbindContext
)(__DRIcontext
*ctx
);
620 * Stored version of some component (i.e., server-side DRI module, kernel-side
624 * There are several data structures that explicitly store a major version,
625 * minor version, and patch level. These structures should be modified to
626 * have a \c __DRIversionRec instead.
628 struct __DRIversionRec
{
629 int major
; /**< Major version number. */
630 int minor
; /**< Minor version number. */
631 int patch
; /**< Patch-level. */
635 * Framebuffer information record. Used by libGL to communicate information
636 * about the framebuffer to the driver's \c __driCreateNewScreen function.
638 * In XFree86, most of this information is derrived from data returned by
639 * calling \c XF86DRIGetDeviceInfo.
641 * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
642 * __driUtilCreateNewScreen CallCreateNewScreen
644 * \bug This structure could be better named.
646 struct __DRIframebufferRec
{
647 unsigned char *base
; /**< Framebuffer base address in the CPU's
648 * address space. This value is calculated by
649 * calling \c drmMap on the framebuffer handle
650 * returned by \c XF86DRIGetDeviceInfo (or a
653 int size
; /**< Framebuffer size, in bytes. */
654 int stride
; /**< Number of bytes from one line to the next. */
655 int width
; /**< Pixel width of the framebuffer. */
656 int height
; /**< Pixel height of the framebuffer. */
657 int dev_priv_size
; /**< Size of the driver's dev-priv structure. */
658 void *dev_priv
; /**< Pointer to the driver's dev-priv structure. */
663 * This extension provides alternative screen, drawable and context
664 * constructors for legacy DRI functionality. This is used in
665 * conjunction with the core extension.
667 #define __DRI_LEGACY "DRI_Legacy"
668 #define __DRI_LEGACY_VERSION 1
670 struct __DRIlegacyExtensionRec
{
673 __DRIscreen
*(*createNewScreen
)(int screen
,
674 const __DRIversion
*ddx_version
,
675 const __DRIversion
*dri_version
,
676 const __DRIversion
*drm_version
,
677 const __DRIframebuffer
*frame_buffer
,
678 void *pSAREA
, int fd
,
679 const __DRIextension
**extensions
,
680 const __DRIconfig
***driver_configs
,
681 void *loaderPrivate
);
683 __DRIdrawable
*(*createNewDrawable
)(__DRIscreen
*screen
,
684 const __DRIconfig
*config
,
685 drm_drawable_t hwDrawable
,
686 int renderType
, const int *attrs
,
687 void *loaderPrivate
);
689 __DRIcontext
*(*createNewContext
)(__DRIscreen
*screen
,
690 const __DRIconfig
*config
,
692 __DRIcontext
*shared
,
693 drm_context_t hwContext
,
694 void *loaderPrivate
);
698 * This extension provides alternative screen, drawable and context
699 * constructors for swrast DRI functionality. This is used in
700 * conjunction with the core extension.
702 #define __DRI_SWRAST "DRI_SWRast"
703 #define __DRI_SWRAST_VERSION 3
705 struct __DRIswrastExtensionRec
{
708 __DRIscreen
*(*createNewScreen
)(int screen
,
709 const __DRIextension
**extensions
,
710 const __DRIconfig
***driver_configs
,
711 void *loaderPrivate
);
713 __DRIdrawable
*(*createNewDrawable
)(__DRIscreen
*screen
,
714 const __DRIconfig
*config
,
715 void *loaderPrivate
);
717 /* Since version 2 */
718 __DRIcontext
*(*createNewContextForAPI
)(__DRIscreen
*screen
,
720 const __DRIconfig
*config
,
721 __DRIcontext
*shared
,
725 * Create a context for a particular API with a set of attributes
729 * \sa __DRIdri2ExtensionRec::createContextAttribs
731 __DRIcontext
*(*createContextAttribs
)(__DRIscreen
*screen
,
733 const __DRIconfig
*config
,
734 __DRIcontext
*shared
,
735 unsigned num_attribs
,
736 const uint32_t *attribs
,
738 void *loaderPrivate
);
742 * DRI2 Loader extension.
744 #define __DRI_BUFFER_FRONT_LEFT 0
745 #define __DRI_BUFFER_BACK_LEFT 1
746 #define __DRI_BUFFER_FRONT_RIGHT 2
747 #define __DRI_BUFFER_BACK_RIGHT 3
748 #define __DRI_BUFFER_DEPTH 4
749 #define __DRI_BUFFER_STENCIL 5
750 #define __DRI_BUFFER_ACCUM 6
751 #define __DRI_BUFFER_FAKE_FRONT_LEFT 7
752 #define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
753 #define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
754 #define __DRI_BUFFER_HIZ 10
756 /* Inofficial and for internal use. Increase when adding a new buffer token. */
757 #define __DRI_BUFFER_COUNT 11
759 struct __DRIbufferRec
{
760 unsigned int attachment
;
767 #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
768 #define __DRI_DRI2_LOADER_VERSION 3
769 struct __DRIdri2LoaderExtensionRec
{
772 __DRIbuffer
*(*getBuffers
)(__DRIdrawable
*driDrawable
,
773 int *width
, int *height
,
774 unsigned int *attachments
, int count
,
775 int *out_count
, void *loaderPrivate
);
778 * Flush pending front-buffer rendering
780 * Any rendering that has been performed to the
781 * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
782 * \c __DRI_BUFFER_FRONT_LEFT.
784 * \param driDrawable Drawable whose front-buffer is to be flushed
785 * \param loaderPrivate Loader's private data that was previously passed
786 * into __DRIdri2ExtensionRec::createNewDrawable
788 void (*flushFrontBuffer
)(__DRIdrawable
*driDrawable
, void *loaderPrivate
);
792 * Get list of buffers from the server
794 * Gets a list of buffer for the specified set of attachments. Unlike
795 * \c ::getBuffers, this function takes a list of attachments paired with
796 * opaque \c unsigned \c int value describing the format of the buffer.
797 * It is the responsibility of the caller to know what the service that
798 * allocates the buffers will expect to receive for the format.
800 * \param driDrawable Drawable whose buffers are being queried.
801 * \param width Output where the width of the buffers is stored.
802 * \param height Output where the height of the buffers is stored.
803 * \param attachments List of pairs of attachment ID and opaque format
804 * requested for the drawable.
805 * \param count Number of attachment / format pairs stored in
807 * \param loaderPrivate Loader's private data that was previously passed
808 * into __DRIdri2ExtensionRec::createNewDrawable.
810 __DRIbuffer
*(*getBuffersWithFormat
)(__DRIdrawable
*driDrawable
,
811 int *width
, int *height
,
812 unsigned int *attachments
, int count
,
813 int *out_count
, void *loaderPrivate
);
817 * This extension provides alternative screen, drawable and context
818 * constructors for DRI2.
820 #define __DRI_DRI2 "DRI_DRI2"
821 #define __DRI_DRI2_VERSION 3
823 #define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
824 #define __DRI_API_GLES 1 /**< OpenGL ES 1.x */
825 #define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */
826 #define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
827 #define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */
829 #define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
830 #define __DRI_CTX_ATTRIB_MINOR_VERSION 1
831 #define __DRI_CTX_ATTRIB_FLAGS 2
834 * \requires __DRI2_ROBUSTNESS.
836 #define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
838 #define __DRI_CTX_FLAG_DEBUG 0x00000001
839 #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
842 * \requires __DRI2_ROBUSTNESS.
844 #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004
847 * \name Context reset strategies.
850 #define __DRI_CTX_RESET_NO_NOTIFICATION 0
851 #define __DRI_CTX_RESET_LOSE_CONTEXT 1
855 * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
859 #define __DRI_CTX_ERROR_SUCCESS 0
861 /** Memory allocation failure */
862 #define __DRI_CTX_ERROR_NO_MEMORY 1
864 /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
865 #define __DRI_CTX_ERROR_BAD_API 2
867 /** Client requested an API version that the driver can't do. */
868 #define __DRI_CTX_ERROR_BAD_VERSION 3
870 /** Client requested a flag or combination of flags the driver can't do. */
871 #define __DRI_CTX_ERROR_BAD_FLAG 4
873 /** Client requested an attribute the driver doesn't understand. */
874 #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
876 /** Client requested a flag the driver doesn't understand. */
877 #define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
880 struct __DRIdri2ExtensionRec
{
883 __DRIscreen
*(*createNewScreen
)(int screen
, int fd
,
884 const __DRIextension
**extensions
,
885 const __DRIconfig
***driver_configs
,
886 void *loaderPrivate
);
888 __DRIdrawable
*(*createNewDrawable
)(__DRIscreen
*screen
,
889 const __DRIconfig
*config
,
890 void *loaderPrivate
);
892 __DRIcontext
*(*createNewContext
)(__DRIscreen
*screen
,
893 const __DRIconfig
*config
,
894 __DRIcontext
*shared
,
895 void *loaderPrivate
);
897 /* Since version 2 */
898 unsigned int (*getAPIMask
)(__DRIscreen
*screen
);
900 __DRIcontext
*(*createNewContextForAPI
)(__DRIscreen
*screen
,
902 const __DRIconfig
*config
,
903 __DRIcontext
*shared
,
906 __DRIbuffer
*(*allocateBuffer
)(__DRIscreen
*screen
,
907 unsigned int attachment
,
911 void (*releaseBuffer
)(__DRIscreen
*screen
,
912 __DRIbuffer
*buffer
);
915 * Create a context for a particular API with a set of attributes
919 * \sa __DRIswrastExtensionRec::createContextAttribs
921 __DRIcontext
*(*createContextAttribs
)(__DRIscreen
*screen
,
923 const __DRIconfig
*config
,
924 __DRIcontext
*shared
,
925 unsigned num_attribs
,
926 const uint32_t *attribs
,
928 void *loaderPrivate
);
933 * This extension provides functionality to enable various EGLImage
936 #define __DRI_IMAGE "DRI_IMAGE"
937 #define __DRI_IMAGE_VERSION 8
940 * These formats correspond to the similarly named MESA_FORMAT_*
941 * tokens, except in the native endian of the CPU. For example, on
942 * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
943 * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
945 * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
946 * by the driver (YUV planar formats) but serve as a base image for
947 * creating sub-images for the different planes within the image.
949 * R8, GR88 and NONE should not be used with createImageFormName or
950 * createImage, and are returned by query from sub images created with
951 * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
953 #define __DRI_IMAGE_FORMAT_RGB565 0x1001
954 #define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
955 #define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
956 #define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
957 #define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
958 #define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
959 #define __DRI_IMAGE_FORMAT_GR88 0x1007
960 #define __DRI_IMAGE_FORMAT_NONE 0x1008
961 #define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
962 #define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
964 #define __DRI_IMAGE_USE_SHARE 0x0001
965 #define __DRI_IMAGE_USE_SCANOUT 0x0002
966 #define __DRI_IMAGE_USE_CURSOR 0x0004 /* Depricated */
967 #define __DRI_IMAGE_USE_LINEAR 0x0008
971 * Four CC formats that matches with WL_DRM_FORMAT_* from wayland_drm.h
972 * and GBM_FORMAT_* from gbm.h, used with createImageFromNames.
977 #define __DRI_IMAGE_FOURCC_RGB565 0x36314752
978 #define __DRI_IMAGE_FOURCC_ARGB8888 0x34325241
979 #define __DRI_IMAGE_FOURCC_XRGB8888 0x34325258
980 #define __DRI_IMAGE_FOURCC_ABGR8888 0x34324241
981 #define __DRI_IMAGE_FOURCC_XBGR8888 0x34324258
982 #define __DRI_IMAGE_FOURCC_YUV410 0x39565559
983 #define __DRI_IMAGE_FOURCC_YUV411 0x31315559
984 #define __DRI_IMAGE_FOURCC_YUV420 0x32315559
985 #define __DRI_IMAGE_FOURCC_YUV422 0x36315559
986 #define __DRI_IMAGE_FOURCC_YUV444 0x34325559
987 #define __DRI_IMAGE_FOURCC_NV12 0x3231564e
988 #define __DRI_IMAGE_FOURCC_NV16 0x3631564e
989 #define __DRI_IMAGE_FOURCC_YUYV 0x56595559
993 * Queryable on images created by createImageFromNames.
995 * RGB and RGBA are may be usable directly as images but its still
996 * recommended to call fromPlanar with plane == 0.
998 * Y_U_V, Y_UV and Y_XUXV all requires call to fromPlanar to create
999 * usable sub-images, sampling from images return raw YUV data and
1000 * color conversion needs to be done in the shader.
1005 #define __DRI_IMAGE_COMPONENTS_RGB 0x3001
1006 #define __DRI_IMAGE_COMPONENTS_RGBA 0x3002
1007 #define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
1008 #define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
1009 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
1013 * queryImage attributes
1016 #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
1017 #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
1018 #define __DRI_IMAGE_ATTRIB_NAME 0x2002
1019 #define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
1020 #define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */
1021 #define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005
1022 #define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */
1023 #define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions
1024 * 7+. Each query will return a
1027 enum __DRIYUVColorSpace
{
1028 __DRI_YUV_COLOR_SPACE_UNDEFINED
= 0,
1029 __DRI_YUV_COLOR_SPACE_ITU_REC601
= 0x327F,
1030 __DRI_YUV_COLOR_SPACE_ITU_REC709
= 0x3280,
1031 __DRI_YUV_COLOR_SPACE_ITU_REC2020
= 0x3281
1034 enum __DRISampleRange
{
1035 __DRI_YUV_RANGE_UNDEFINED
= 0,
1036 __DRI_YUV_FULL_RANGE
= 0x3282,
1037 __DRI_YUV_NARROW_RANGE
= 0x3283
1040 enum __DRIChromaSiting
{
1041 __DRI_YUV_CHROMA_SITING_UNDEFINED
= 0,
1042 __DRI_YUV_CHROMA_SITING_0
= 0x3284,
1043 __DRI_YUV_CHROMA_SITING_0_5
= 0x3285
1047 * \name Reasons that __DRIimageExtensionRec::createImageFromTexture might fail
1051 #define __DRI_IMAGE_ERROR_SUCCESS 0
1053 /** Memory allocation failure */
1054 #define __DRI_IMAGE_ERROR_BAD_ALLOC 1
1056 /** Client requested an invalid attribute for a texture object */
1057 #define __DRI_IMAGE_ERROR_BAD_MATCH 2
1059 /** Client requested an invalid texture object */
1060 #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
1063 typedef struct __DRIimageRec __DRIimage
;
1064 typedef struct __DRIimageExtensionRec __DRIimageExtension
;
1065 struct __DRIimageExtensionRec
{
1066 __DRIextension base
;
1068 __DRIimage
*(*createImageFromName
)(__DRIscreen
*screen
,
1069 int width
, int height
, int format
,
1070 int name
, int pitch
,
1071 void *loaderPrivate
);
1073 __DRIimage
*(*createImageFromRenderbuffer
)(__DRIcontext
*context
,
1075 void *loaderPrivate
);
1077 void (*destroyImage
)(__DRIimage
*image
);
1079 __DRIimage
*(*createImage
)(__DRIscreen
*screen
,
1080 int width
, int height
, int format
,
1082 void *loaderPrivate
);
1084 GLboolean (*queryImage
)(__DRIimage
*image
, int attrib
, int *value
);
1087 * The new __DRIimage will share the content with the old one, see dup(2).
1089 __DRIimage
*(*dupImage
)(__DRIimage
*image
, void *loaderPrivate
);
1092 * Validate that a __DRIimage can be used a certain way.
1096 GLboolean (*validateUsage
)(__DRIimage
*image
, unsigned int use
);
1099 * Unlike createImageFromName __DRI_IMAGE_FORMAT is not but instead
1100 * __DRI_IMAGE_FOURCC and strides are in bytes not pixels. Stride is
1101 * also per block and not per pixel (for non-RGB, see gallium blocks).
1105 __DRIimage
*(*createImageFromNames
)(__DRIscreen
*screen
,
1106 int width
, int height
, int fourcc
,
1107 int *names
, int num_names
,
1108 int *strides
, int *offsets
,
1109 void *loaderPrivate
);
1112 * Create an image out of a sub-region of a parent image. This
1113 * entry point lets us create individual __DRIimages for different
1114 * planes in a planar buffer (typically yuv), for example. While a
1115 * sub-image shares the underlying buffer object with the parent
1116 * image and other sibling sub-images, the life times of parent and
1117 * sub-images are not dependent. Destroying the parent or a
1118 * sub-image doesn't affect other images. The underlying buffer
1119 * object is free when no __DRIimage remains that references it.
1121 * Sub-images may overlap, but rendering to overlapping sub-images
1126 __DRIimage
*(*fromPlanar
)(__DRIimage
*image
, int plane
,
1127 void *loaderPrivate
);
1130 * Create image from texture.
1134 __DRIimage
*(*createImageFromTexture
)(__DRIcontext
*context
,
1140 void *loaderPrivate
);
1142 * Like createImageFromNames, but takes a prime fd instead.
1146 __DRIimage
*(*createImageFromFds
)(__DRIscreen
*screen
,
1147 int width
, int height
, int fourcc
,
1148 int *fds
, int num_fds
,
1149 int *strides
, int *offsets
,
1150 void *loaderPrivate
);
1153 * Like createImageFromFds, but takes additional attributes.
1155 * For EGL_EXT_image_dma_buf_import.
1159 __DRIimage
*(*createImageFromDmaBufs
)(__DRIscreen
*screen
,
1160 int width
, int height
, int fourcc
,
1161 int *fds
, int num_fds
,
1162 int *strides
, int *offsets
,
1163 enum __DRIYUVColorSpace color_space
,
1164 enum __DRISampleRange sample_range
,
1165 enum __DRIChromaSiting horiz_siting
,
1166 enum __DRIChromaSiting vert_siting
,
1168 void *loaderPrivate
);
1173 * This extension must be implemented by the loader and passed to the
1174 * driver at screen creation time. The EGLImage entry points in the
1175 * various client APIs take opaque EGLImage handles and use this
1176 * extension to map them to a __DRIimage. At version 1, this
1177 * extensions allows mapping EGLImage pointers to __DRIimage pointers,
1178 * but future versions could support other EGLImage-like, opaque types
1179 * with new lookup functions.
1181 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
1182 #define __DRI_IMAGE_LOOKUP_VERSION 1
1184 typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension
;
1185 struct __DRIimageLookupExtensionRec
{
1186 __DRIextension base
;
1188 __DRIimage
*(*lookupEGLImage
)(__DRIscreen
*screen
, void *image
,
1189 void *loaderPrivate
);
1193 * This extension allows for common DRI2 options
1195 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
1196 #define __DRI2_CONFIG_QUERY_VERSION 1
1198 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension
;
1199 struct __DRI2configQueryExtensionRec
{
1200 __DRIextension base
;
1202 int (*configQueryb
)(__DRIscreen
*screen
, const char *var
, GLboolean
*val
);
1203 int (*configQueryi
)(__DRIscreen
*screen
, const char *var
, GLint
*val
);
1204 int (*configQueryf
)(__DRIscreen
*screen
, const char *var
, GLfloat
*val
);
1208 * Robust context driver extension.
1210 * Existence of this extension means the driver can accept the
1211 * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
1212 * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
1213 * \c __DRIdri2ExtensionRec::createContextAttribs.
1215 #define __DRI2_ROBUSTNESS "DRI_Robustness"
1216 #define __DRI2_ROBUSTNESS_VERSION 1
1218 typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension
;
1219 struct __DRIrobustnessExtensionRec
{
1220 __DRIextension base
;
1224 * DRI config options extension.
1226 * This extension provides the XML string containing driver options for use by
1227 * the loader in supporting the driconf application.
1229 #define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
1230 #define __DRI_CONFIG_OPTIONS_VERSION 1
1232 typedef struct __DRIconfigOptionsExtensionRec
{
1233 __DRIextension base
;
1235 } __DRIconfigOptionsExtension
;