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