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