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 * Copyright © 2022 Google LLC 7 * 8 * Permission is hereby granted, free of charge, to any person obtaining a 9 * copy of this software and associated documentation files (the "Software"), 10 * to deal in the Software without restriction, including without limitation 11 * the rights to use, copy, modify, merge, publish, distribute, sublicense, 12 * and/or sell copies of the Software, and to permit persons to whom the 13 * Software is furnished to do so, subject to the following conditions: 14 * 15 * The above copyright notice and this permission notice (including the next 16 * paragraph) shall be included in all copies or substantial portions of the 17 * Software. 18 * 19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 20 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 22 * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 23 * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 24 * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 25 * IN THE SOFTWARE. 26 */ 27 28 #ifndef MESA_INTERFACE_H 29 #define MESA_INTERFACE_H 30 31 #include <stdbool.h> 32 #include <stdint.h> 33 34 struct dri_screen; 35 struct dri_context; 36 struct dri_drawable; 37 struct dri_config; 38 struct dri_image; 39 40 /** 41 * Extension struct. Drivers 'inherit' from this struct by embedding 42 * it as the first element in the extension struct. 43 * 44 * We never break API in for a DRI extension. If we need to change 45 * the way things work in a non-backwards compatible manner, we 46 * introduce a new extension. During a transition period, we can 47 * leave both the old and the new extension in the driver, which 48 * allows us to move to the new interface without having to update the 49 * loader(s) in lock step. 50 * 51 * However, we can add entry points to an extension over time as long 52 * as we don't break the old ones. As we add entry points to an 53 * extension, we increase the version number. The corresponding 54 * #define can be used to guard code that accesses the new entry 55 * points at compile time and the version field in the extension 56 * struct can be used at run-time to determine how to use the 57 * extension. 58 */ 59 typedef struct { 60 const char *name; 61 int version; 62 } __DRIextension; 63 64 /** 65 * The first set of extension are the screen extensions, returned by 66 * __DRIcore::getExtensions(). This entry point will return a list of 67 * extensions and the loader can use the ones it knows about by 68 * casting them to more specific extensions and advertising any GLX 69 * extensions the DRI extensions enables. 70 */ 71 72 /* Valid values for format in the setTexBuffer2 function below. These 73 * values match the GLX tokens for compatibility reasons, but we 74 * define them here since the DRI interface can't depend on GLX. */ 75 #define __DRI_TEXTURE_FORMAT_RGB 0x20D9 76 #define __DRI_TEXTURE_FORMAT_RGBA 0x20DA 77 78 #define __DRI_TEX_BUFFER "DRI_TexBuffer" 79 typedef struct { 80 __DRIextension base; 81 82 /** 83 * Method to override base texture image with the contents of a 84 * struct dri_drawable, including the required texture format attribute. 85 * 86 * For GLX_EXT_texture_from_pixmap with AIGLX. Used by the X server since 87 * 2011. 88 * 89 * \since 2 90 */ 91 void (*setTexBuffer2)(struct dri_context *pDRICtx, 92 int target, 93 int format, 94 struct dri_drawable *pDraw); 95 } __DRItexBufferExtension; 96 97 /** 98 * Used by drivers that implement DRI2. Version 3 is used by the X server. 99 */ 100 #define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */ 101 #define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */ 102 #define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2) 103 104 enum __DRI2throttleReason { 105 __DRI2_THROTTLE_SWAPBUFFER, 106 __DRI2_THROTTLE_COPYSUBBUFFER, 107 __DRI2_THROTTLE_FLUSHFRONT, 108 __DRI2_NOTHROTTLE_SWAPBUFFER, 109 }; 110 111 /** 112 * Extension for EGL_ANDROID_blob_cache 113 * * 114 * Not used by the X server. 115 */ 116 typedef void 117 (*__DRIblobCacheSet) (const void *key, signed long keySize, 118 const void *value, signed long valueSize); 119 120 typedef signed long 121 (*__DRIblobCacheGet) (const void *key, signed long keySize, 122 void *value, signed long valueSize); 123 124 /** 125 * Extension for fences / synchronization objects. 126 * * 127 * Not used by the X server. 128 */ 129 130 #define __DRI2_FENCE "DRI2_Fence" 131 132 #define __DRI2_FENCE_FLAG_FLUSH_COMMANDS (1 << 0) 133 134 /** 135 * \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities 136 */ 137 /*@{*/ 138 #define __DRI_FENCE_CAP_NATIVE_FD 1 139 /*@}*/ 140 141 typedef struct { 142 __DRIextension base; 143 144 /** 145 * Create and insert a fence into the command stream of the context. 146 */ 147 void *(*create_fence)(struct dri_context *ctx); 148 149 /** 150 * Get a fence associated with the OpenCL event object. 151 * This can be NULL, meaning that OpenCL interoperability is not supported. 152 */ 153 void *(*get_fence_from_cl_event)(struct dri_screen *screen, intptr_t cl_event); 154 155 /** 156 * Destroy a fence. 157 */ 158 void (*destroy_fence)(struct dri_screen *screen, void *fence); 159 160 /** 161 * This function waits and doesn't return until the fence is signalled 162 * or the timeout expires. It returns true if the fence has been signaled. 163 * 164 * \param ctx the context where commands are flushed 165 * \param fence the fence 166 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags 167 * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE 168 */ 169 unsigned char (*client_wait_sync)(struct dri_context *ctx, void *fence, 170 unsigned flags, uint64_t timeout); 171 172 /** 173 * This function enqueues a wait command into the command stream of 174 * the context and then returns. When the execution reaches the wait 175 * command, no further execution will be done in the context until 176 * the fence is signaled. This is a no-op if the device doesn't support 177 * parallel execution of contexts. 178 * 179 * \param ctx the context where the waiting is done 180 * \param fence the fence 181 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags that make 182 * sense with this function (right now there are none) 183 */ 184 void (*server_wait_sync)(struct dri_context *ctx, void *fence, unsigned flags); 185 186 /** 187 * Query for general capabilities of the driver that concern fences. 188 * Returns a bitmask of __DRI_FENCE_CAP_x 189 * 190 * \since 2 191 */ 192 unsigned (*get_capabilities)(struct dri_screen *screen); 193 194 /** 195 * Create an fd (file descriptor) associated fence. If the fence fd 196 * is -1, this behaves similarly to create_fence() except that when 197 * rendering is flushed the driver creates a fence fd. Otherwise, 198 * the driver wraps an existing fence fd. 199 * 200 * This is used to implement the EGL_ANDROID_native_fence_sync extension. 201 * 202 * \since 2 203 * 204 * \param ctx the context associated with the fence 205 * \param fd the fence fd or -1 206 */ 207 void *(*create_fence_fd)(struct dri_context *ctx, int fd); 208 209 /** 210 * For fences created with create_fence_fd(), after rendering is flushed, 211 * this retrieves the native fence fd. Caller takes ownership of the 212 * fd and will close() it when it is no longer needed. 213 * 214 * \since 2 215 * 216 * \param screen the screen associated with the fence 217 * \param fence the fence 218 */ 219 int (*get_fence_fd)(struct dri_screen *screen, void *fence); 220 } __DRI2fenceExtension; 221 222 /** 223 * Extension for limiting window system back buffer rendering to user-defined 224 * scissor region. 225 * 226 * Not used by the X server. 227 */ 228 typedef struct { 229 __DRIextension base; 230 231 /** 232 * Provides an array of rectangles representing an overriding scissor region 233 * for rendering operations performed to the specified drawable. These 234 * rectangles do not replace client API scissor regions or draw 235 * co-ordinates, but instead inform the driver of the overall bounds of all 236 * operations which will be issued before the next flush. 237 * 238 * Any rendering operations writing pixels outside this region to the 239 * drawable will have an undefined effect on the entire drawable. 240 * 241 * This entrypoint may only be called after the drawable has either been 242 * newly created or flushed, and before any rendering operations which write 243 * pixels to the drawable. Calling this entrypoint at any other time will 244 * have an undefined effect on the entire drawable. 245 * 246 * Calling this entrypoint with @nrects 0 and @rects NULL will reset the 247 * region to the buffer's full size. This entrypoint may be called once to 248 * reset the region, followed by a second call with a populated region, 249 * before a rendering call is made. 250 * 251 * Used to implement EGL_KHR_partial_update. 252 * 253 * \param drawable affected drawable 254 * \param nrects number of rectangles provided 255 * \param rects the array of rectangles, lower-left origin 256 */ 257 void (*set_damage_region)(struct dri_drawable *drawable, unsigned int nrects, 258 int *rects); 259 } __DRI2bufferDamageExtension; 260 261 /*@}*/ 262 263 /** 264 * The following extensions describe loader features that the DRI 265 * driver can make use of. Some of these are mandatory, such as the 266 * getDrawableInfo extension for DRI and the DRI Loader extensions for 267 * DRI2, while others are optional, and if present allow the driver to 268 * expose certain features. The loader pass in a NULL terminated 269 * array of these extensions to the driver in the createNewScreen 270 * constructor. 271 */ 272 273 #define __DRI_SWRAST_IMAGE_OP_DRAW 1 274 #define __DRI_SWRAST_IMAGE_OP_SWAP 3 275 276 /** 277 * SWRast Loader extension. 278 * 279 * Version 1 is advertised by the X server. 280 */ 281 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader" 282 typedef struct { 283 __DRIextension base; 284 285 /* 286 * Drawable position and size 287 */ 288 void (*getDrawableInfo)(struct dri_drawable *drawable, 289 int *x, int *y, int *width, int *height, 290 void *loaderPrivate); 291 292 /** 293 * Put image to drawable 294 */ 295 void (*putImage)(struct dri_drawable *drawable, int op, 296 int x, int y, int width, int height, 297 char *data, void *loaderPrivate); 298 299 /** 300 * Get image from readable 301 */ 302 void (*getImage)(struct dri_drawable *readable, 303 int x, int y, int width, int height, 304 char *data, void *loaderPrivate); 305 306 /** 307 * Put image to drawable 308 * 309 * \since 2 310 */ 311 void (*putImage2)(struct dri_drawable *drawable, int op, 312 int x, int y, int width, int height, int stride, 313 char *data, void *loaderPrivate); 314 315 /** 316 * Put image to drawable 317 * 318 * \since 3 319 */ 320 void (*getImage2)(struct dri_drawable *readable, 321 int x, int y, int width, int height, int stride, 322 char *data, void *loaderPrivate); 323 324 /** 325 * Put shm image to drawable 326 * 327 * \since 4 328 */ 329 void (*putImageShm)(struct dri_drawable *drawable, int op, 330 int x, int y, int width, int height, int stride, 331 int shmid, char *shmaddr, unsigned offset, 332 void *loaderPrivate); 333 /** 334 * Get shm image from readable 335 * 336 * \since 4 337 */ 338 void (*getImageShm)(struct dri_drawable *readable, 339 int x, int y, int width, int height, 340 int shmid, void *loaderPrivate); 341 342 /** 343 * Put shm image to drawable (v2) 344 * 345 * The original version fixes srcx/y to 0, and expected 346 * the offset to be adjusted. This version allows src x,y 347 * to not be included in the offset. This is needed to 348 * avoid certain overflow checks in the X server, that 349 * result in lost rendering. 350 * 351 * \since 5 352 */ 353 void (*putImageShm2)(struct dri_drawable *drawable, int op, 354 int x, int y, 355 int width, int height, int stride, 356 int shmid, char *shmaddr, unsigned offset, 357 void *loaderPrivate); 358 359 /** 360 * get shm image to drawable (v2) 361 * 362 * There are some cases where GLX can't use SHM, but DRI 363 * still tries, we need to get a return type for when to 364 * fallback to the non-shm path. 365 * 366 * \since 6 367 */ 368 unsigned char (*getImageShm2)(struct dri_drawable *readable, 369 int x, int y, int width, int height, 370 int shmid, void *loaderPrivate); 371 } __DRIswrastLoaderExtension; 372 373 /** 374 * Invalidate loader extension. The presence of this extension 375 * indicates to the DRI driver that the loader will call invalidate in 376 * the __DRI2_FLUSH extension, whenever the needs to query for new 377 * buffers. This means that the DRI driver can drop the polling in 378 * glViewport(). 379 * 380 * The extension doesn't provide any functionality, it's only use to 381 * indicate to the driver that it can use the new semantics. A DRI 382 * driver can use this to switch between the different semantics or 383 * just refuse to initialize if this extension isn't present. 384 * 385 * Advertised by the X server. 386 */ 387 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate" 388 389 typedef struct { 390 __DRIextension base; 391 } __DRIuseInvalidateExtension; 392 393 /** 394 * Tokens for struct dri_config attribs. A number of attributes defined by 395 * GLX or EGL standards are not in the table, as they must be provided 396 * by the loader. For example, FBConfig ID or visual ID, drawable type. 397 */ 398 399 #define __DRI_ATTRIB_BUFFER_SIZE 1 400 #define __DRI_ATTRIB_LEVEL 2 401 #define __DRI_ATTRIB_RED_SIZE 3 402 #define __DRI_ATTRIB_GREEN_SIZE 4 403 #define __DRI_ATTRIB_BLUE_SIZE 5 404 #define __DRI_ATTRIB_LUMINANCE_SIZE 6 405 #define __DRI_ATTRIB_ALPHA_SIZE 7 406 #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8 407 #define __DRI_ATTRIB_DEPTH_SIZE 9 408 #define __DRI_ATTRIB_STENCIL_SIZE 10 409 #define __DRI_ATTRIB_ACCUM_RED_SIZE 11 410 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12 411 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13 412 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14 413 #define __DRI_ATTRIB_SAMPLE_BUFFERS 15 414 #define __DRI_ATTRIB_SAMPLES 16 415 #define __DRI_ATTRIB_RENDER_TYPE 17 416 #define __DRI_ATTRIB_CONFIG_CAVEAT 18 417 #define __DRI_ATTRIB_CONFORMANT 19 418 #define __DRI_ATTRIB_DOUBLE_BUFFER 20 419 #define __DRI_ATTRIB_STEREO 21 420 #define __DRI_ATTRIB_AUX_BUFFERS 22 421 #define __DRI_ATTRIB_TRANSPARENT_TYPE 23 422 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24 423 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25 424 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26 425 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27 426 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28 427 #define __DRI_ATTRIB_FLOAT_MODE 29 428 #define __DRI_ATTRIB_RED_MASK 30 429 #define __DRI_ATTRIB_GREEN_MASK 31 430 #define __DRI_ATTRIB_BLUE_MASK 32 431 #define __DRI_ATTRIB_ALPHA_MASK 33 432 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34 433 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35 434 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36 435 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37 436 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38 437 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39 438 #define __DRI_ATTRIB_SWAP_METHOD 40 // Parsed by the X server when our visuals return it as an attrib. 439 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41 440 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42 441 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43 442 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44 443 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45 444 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46 445 #define __DRI_ATTRIB_YINVERTED 47 446 #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48 447 #define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER 49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */ 448 #define __DRI_ATTRIB_RED_SHIFT 50 449 #define __DRI_ATTRIB_GREEN_SHIFT 51 450 #define __DRI_ATTRIB_BLUE_SHIFT 52 451 #define __DRI_ATTRIB_ALPHA_SHIFT 53 452 #define __DRI_ATTRIB_MAX 54 453 454 /* __DRI_ATTRIB_RENDER_TYPE */ 455 #define __DRI_ATTRIB_RGBA_BIT 0x01 456 #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02 457 #define __DRI_ATTRIB_LUMINANCE_BIT 0x04 458 #define __DRI_ATTRIB_FLOAT_BIT 0x08 459 #define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10 460 461 /* __DRI_ATTRIB_CONFIG_CAVEAT */ 462 #define __DRI_ATTRIB_SLOW_BIT 0x01 463 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02 464 465 /* __DRI_ATTRIB_TRANSPARENT_TYPE */ 466 #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00 467 #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01 468 469 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */ 470 #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01 471 #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02 472 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04 473 474 /* __DRI_ATTRIB_SWAP_METHOD */ 475 /* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define 476 * the same tokens as GLX. This is because old and current X servers will 477 * transmit the driconf value grabbed from the AIGLX driver untranslated as 478 * the GLX fbconfig value. These defines are kept for X Server suorce compatibility, 479 * since Mesa no longer exposes GLX_OML_swap_method. 480 */ 481 #define __DRI_ATTRIB_SWAP_UNDEFINED 0x8063 482 483 /** 484 * This extension defines the core DRI functionality. It was introduced when 485 * DRI2 and AIGLX were added. 486 * 487 * Version >= 2 indicates that getConfigAttrib with __DRI_ATTRIB_SWAP_METHOD 488 * returns a reliable value. The X server requires v1 and uses v2. 489 */ 490 typedef struct { 491 __DRIextension base; 492 493 /* Not used by the X server. */ 494 struct dri_screen *(*createNewScreen)(int screen, int fd, 495 unsigned int sarea_handle, 496 const __DRIextension **extensions, 497 const struct dri_config ***driverConfigs, 498 void *loaderPrivate); 499 500 void (*destroyScreen)(struct dri_screen *screen); 501 502 const __DRIextension **(*getExtensions)(struct dri_screen *screen); 503 504 /* Not used by the X server. */ 505 int (*getConfigAttrib)(const struct dri_config *config, 506 unsigned int attrib, 507 unsigned int *value); 508 509 /* Not used by the X server. */ 510 int (*indexConfigAttrib)(const struct dri_config *config, int index, 511 unsigned int *attrib, unsigned int *value); 512 513 /* Not used by the X server. */ 514 struct dri_drawable *(*createNewDrawable)(struct dri_screen *screen, 515 const struct dri_config *config, 516 unsigned int drawable_id, 517 unsigned int head, 518 void *loaderPrivate); 519 520 /* Used by the X server */ 521 void (*destroyDrawable)(struct dri_drawable *drawable); 522 523 /* Used by the X server in swrast mode. */ 524 void (*swapBuffers)(struct dri_drawable *drawable); 525 526 /* Used by the X server in swrast mode. */ 527 struct dri_context *(*createNewContext)(struct dri_screen *screen, 528 const struct dri_config *config, 529 struct dri_context *shared, 530 void *loaderPrivate); 531 532 /* Used by the X server. */ 533 int (*copyContext)(struct dri_context *dest, 534 struct dri_context *src, 535 unsigned long mask); 536 537 /* Used by the X server. */ 538 void (*destroyContext)(struct dri_context *context); 539 540 /* Used by the X server. */ 541 int (*bindContext)(struct dri_context *ctx, 542 struct dri_drawable *pdraw, 543 struct dri_drawable *pread); 544 545 /* Used by the X server. */ 546 int (*unbindContext)(struct dri_context *ctx); 547 548 void (*swapBuffersWithDamage)(struct dri_drawable *drawable, int nrects, const int *rects); 549 } __DRIcoreExtension; 550 551 /** Common DRI function definitions, shared among DRI2 and Image extensions 552 */ 553 554 typedef struct dri_screen * 555 (*__DRIcreateNewScreen2Func)(int screen, int fd, 556 const __DRIextension **extensions, 557 const __DRIextension **driver_extensions, 558 const struct dri_config ***driver_configs, 559 void *loaderPrivate); 560 typedef struct dri_screen * 561 (*__DRIcreateNewScreen3Func)(int screen, int fd, 562 const __DRIextension **extensions, 563 const __DRIextension **driver_extensions, 564 const struct dri_config ***driver_configs, 565 bool implicit, 566 void *loaderPrivate); 567 568 typedef struct dri_drawable * 569 (*__DRIcreateNewDrawableFunc)(struct dri_screen *screen, 570 const struct dri_config *config, 571 void *loaderPrivate); 572 573 typedef struct dri_context * 574 (*__DRIcreateContextAttribsFunc)(struct dri_screen *screen, 575 int api, 576 const struct dri_config *config, 577 struct dri_context *shared, 578 unsigned num_attribs, 579 const uint32_t *attribs, 580 unsigned *error, 581 void *loaderPrivate); 582 583 typedef unsigned int 584 (*__DRIgetAPIMaskFunc)(struct dri_screen *screen); 585 586 /** 587 * DRI2 Loader extension. 588 */ 589 #define __DRI_BUFFER_FRONT_LEFT 0 590 #define __DRI_BUFFER_BACK_LEFT 1 591 #define __DRI_BUFFER_FRONT_RIGHT 2 592 #define __DRI_BUFFER_BACK_RIGHT 3 593 #define __DRI_BUFFER_DEPTH 4 594 #define __DRI_BUFFER_STENCIL 5 595 #define __DRI_BUFFER_FAKE_FRONT_LEFT 6 596 #define __DRI_BUFFER_FAKE_FRONT_RIGHT 7 597 #define __DRI_BUFFER_DEPTH_STENCIL 8 /**< Only available with DRI2 1.1 */ 598 599 /* Inofficial and for internal use. Increase when adding a new buffer token. */ 600 #define __DRI_BUFFER_COUNT 9 601 602 /* Used by the X server. */ 603 typedef struct { 604 unsigned int attachment; 605 unsigned int name; 606 unsigned int pitch; 607 unsigned int cpp; 608 unsigned int flags; 609 } __DRIbuffer; 610 611 /* The X server implements up to version 3 of the DRI2 loader. */ 612 #define __DRI_DRI2_LOADER "DRI_DRI2Loader" 613 614 enum dri_loader_cap { 615 /* Whether the loader handles RGBA channel ordering correctly. If not, 616 * only BGRA ordering can be exposed. 617 */ 618 DRI_LOADER_CAP_RGBA_ORDERING, 619 DRI_LOADER_CAP_FP16, 620 }; 621 622 typedef struct { 623 __DRIextension base; 624 625 __DRIbuffer *(*getBuffers)(struct dri_drawable *driDrawable, 626 int *width, int *height, 627 unsigned int *attachments, int count, 628 int *out_count, void *loaderPrivate); 629 630 /** 631 * Flush pending front-buffer rendering 632 * 633 * Any rendering that has been performed to the 634 * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the 635 * \c __DRI_BUFFER_FRONT_LEFT. 636 * 637 * \param driDrawable Drawable whose front-buffer is to be flushed 638 * \param loaderPrivate Loader's private data 639 * 640 * \since 2 641 */ 642 void (*flushFrontBuffer)(struct dri_drawable *driDrawable, void *loaderPrivate); 643 644 645 /** 646 * Get list of buffers from the server 647 * 648 * Gets a list of buffer for the specified set of attachments. Unlike 649 * \c ::getBuffers, this function takes a list of attachments paired with 650 * opaque \c unsigned \c int value describing the format of the buffer. 651 * It is the responsibility of the caller to know what the service that 652 * allocates the buffers will expect to receive for the format. 653 * 654 * \param driDrawable Drawable whose buffers are being queried. 655 * \param width Output where the width of the buffers is stored. 656 * \param height Output where the height of the buffers is stored. 657 * \param attachments List of pairs of attachment ID and opaque format 658 * requested for the drawable. 659 * \param count Number of attachment / format pairs stored in 660 * \c attachments. 661 * \param loaderPrivate Loader's private data 662 * 663 * \since 3 664 */ 665 __DRIbuffer *(*getBuffersWithFormat)(struct dri_drawable *driDrawable, 666 int *width, int *height, 667 unsigned int *attachments, int count, 668 int *out_count, void *loaderPrivate); 669 670 /** 671 * Return a loader capability value. If the loader doesn't know the enum, 672 * it will return 0. 673 * 674 * \param loaderPrivate The last parameter of createNewScreen or 675 * createNewScreen2. 676 * \param cap See the enum. 677 * 678 * \since 4 679 */ 680 unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap); 681 682 /** 683 * Clean up any loader state associated with an image. 684 * 685 * \param loaderPrivate Loader's private data that was previously passed 686 * into a __DRIimageExtensionRec::createImage function 687 * \since 5 688 */ 689 void (*destroyLoaderImageState)(void *loaderPrivate); 690 } __DRIdri2LoaderExtension; 691 692 /** 693 * This extension provides alternative screen, drawable and context 694 * constructors for DRI2. The X server uses up to version 4. 695 */ 696 #define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */ 697 #define __DRI_API_GLES 1 /**< OpenGL ES 1.x */ 698 #define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */ 699 #define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */ 700 #define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */ 701 702 #define __DRI_CTX_ATTRIB_MAJOR_VERSION 0 703 #define __DRI_CTX_ATTRIB_MINOR_VERSION 1 704 705 /* These must alias the GLX/EGL values. */ 706 #define __DRI_CTX_ATTRIB_FLAGS 2 707 #define __DRI_CTX_FLAG_DEBUG 0x00000001 708 #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002 709 #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004 710 /* Not yet implemented but placed here to reserve the alias with GLX */ 711 #define __DRI_CTX_FLAG_RESET_ISOLATION 0x00000008 712 713 #define __DRI_CTX_ATTRIB_RESET_STRATEGY 3 714 #define __DRI_CTX_RESET_NO_NOTIFICATION 0 715 #define __DRI_CTX_RESET_LOSE_CONTEXT 1 716 717 /** 718 * \name Context priority levels. 719 */ 720 #define __DRI_CTX_ATTRIB_PRIORITY 4 721 #define __DRI_CTX_PRIORITY_LOW 0 722 #define __DRI_CTX_PRIORITY_MEDIUM 1 723 #define __DRI_CTX_PRIORITY_HIGH 2 724 #define __DRI_CTX_PRIORITY_REALTIME 3 725 726 #define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR 5 727 #define __DRI_CTX_RELEASE_BEHAVIOR_NONE 0 728 #define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH 1 729 730 #define __DRI_CTX_ATTRIB_NO_ERROR 6 731 732 /** 733 * \requires __DRI2_RENDER_HAS_PROTECTED_CONTEXT. 734 * 735 */ 736 #define __DRI_CTX_ATTRIB_PROTECTED 7 737 738 739 #define __DRI_CTX_NUM_ATTRIBS 8 740 741 /** 742 * \name Reasons that createContextAttribs might fail 743 */ 744 /*@{*/ 745 /** Success! */ 746 #define __DRI_CTX_ERROR_SUCCESS 0 747 748 /** Memory allocation failure */ 749 #define __DRI_CTX_ERROR_NO_MEMORY 1 750 751 /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */ 752 #define __DRI_CTX_ERROR_BAD_API 2 753 754 /** Client requested an API version that the driver can't do. */ 755 #define __DRI_CTX_ERROR_BAD_VERSION 3 756 757 /** Client requested a flag or combination of flags the driver can't do. */ 758 #define __DRI_CTX_ERROR_BAD_FLAG 4 759 760 /** Client requested an attribute the driver doesn't understand. */ 761 #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5 762 763 /** Client requested a flag the driver doesn't understand. */ 764 #define __DRI_CTX_ERROR_UNKNOWN_FLAG 6 765 /*@}*/ 766 767 768 /** 769 * This extension provides functionality to enable various EGLImage 770 * extensions. 771 */ 772 /* __DRI_IMAGE_FORMAT_* tokens are no longer exported */ 773 774 #define __DRI_IMAGE_USE_SHARE 0x0001 775 #define __DRI_IMAGE_USE_SCANOUT 0x0002 776 #define __DRI_IMAGE_USE_CURSOR 0x0004 /* Deprecated */ 777 #define __DRI_IMAGE_USE_LINEAR 0x0008 778 /* The buffer will only be read by an external process after SwapBuffers, 779 * in contrary to gbm buffers, front buffers and fake front buffers, which 780 * could be read after a flush." 781 */ 782 #define __DRI_IMAGE_USE_BACKBUFFER 0x0010 783 #define __DRI_IMAGE_USE_PROTECTED 0x0020 784 #define __DRI_IMAGE_USE_PRIME_BUFFER 0x0040 785 #define __DRI_IMAGE_USE_FRONT_RENDERING 0x0080 786 787 788 #define __DRI_IMAGE_TRANSFER_READ 0x1 789 #define __DRI_IMAGE_TRANSFER_WRITE 0x2 790 #define __DRI_IMAGE_TRANSFER_READ_WRITE \ 791 (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE) 792 793 /** 794 * Extra fourcc formats used internally to Mesa with createImageFromNames. 795 * The externally-available fourccs are defined by drm_fourcc.h (DRM_FORMAT_*) 796 * and WL_DRM_FORMAT_* from wayland_drm.h. 797 * 798 * \since 5 799 */ 800 801 #define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258 802 #define __DRI_IMAGE_FOURCC_SABGR8888 0x84324258 803 #define __DRI_IMAGE_FOURCC_SXRGB8888 0x85324258 804 805 /** 806 * Queryable on images created by createImageFromNames. 807 * 808 * RGB and RGBA might be usable directly as images, but it's still 809 * recommended to call fromPlanar with plane == 0. 810 * 811 * Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create 812 * usable sub-images, sampling from images return raw YUV data and 813 * color conversion needs to be done in the shader. 814 * 815 * \since 5 816 */ 817 818 #define __DRI_IMAGE_COMPONENTS_RGB 0x3001 819 #define __DRI_IMAGE_COMPONENTS_RGBA 0x3002 820 #define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003 821 #define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004 822 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 823 #define __DRI_IMAGE_COMPONENTS_Y_UXVX 0x3008 824 #define __DRI_IMAGE_COMPONENTS_AYUV 0x3009 825 #define __DRI_IMAGE_COMPONENTS_XYUV 0x300A 826 #define __DRI_IMAGE_COMPONENTS_R 0x3006 827 #define __DRI_IMAGE_COMPONENTS_RG 0x3007 828 829 830 /** 831 * queryImage attributes 832 */ 833 834 #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000 835 #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001 836 #define __DRI_IMAGE_ATTRIB_NAME 0x2002 837 #define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */ 838 #define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */ 839 #define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005 840 #define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */ 841 #define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions 842 * 7+. Each query will return a 843 * new fd. */ 844 #define __DRI_IMAGE_ATTRIB_FOURCC 0x2008 /* available in versions 11 */ 845 #define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */ 846 847 #define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */ 848 #define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */ 849 #define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */ 850 #define __DRI_IMAGE_ATTRIB_COMPRESSION_RATE 0x200D /* available in versions 22 */ 851 852 enum __DRIYUVColorSpace { 853 __DRI_YUV_COLOR_SPACE_UNDEFINED = 0, 854 __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F, 855 __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280, 856 __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281 857 }; 858 859 enum __DRISampleRange { 860 __DRI_YUV_RANGE_UNDEFINED = 0, 861 __DRI_YUV_FULL_RANGE = 0x3282, 862 __DRI_YUV_NARROW_RANGE = 0x3283 863 }; 864 865 enum __DRIChromaSiting { 866 __DRI_YUV_CHROMA_SITING_UNDEFINED = 0, 867 __DRI_YUV_CHROMA_SITING_0 = 0x3284, 868 __DRI_YUV_CHROMA_SITING_0_5 = 0x3285 869 }; 870 871 enum __DRIFixedRateCompression { 872 __DRI_FIXED_RATE_COMPRESSION_NONE = 0x34B1, 873 __DRI_FIXED_RATE_COMPRESSION_DEFAULT = 0x34B2, 874 875 __DRI_FIXED_RATE_COMPRESSION_1BPC = 0x34B4, 876 __DRI_FIXED_RATE_COMPRESSION_2BPC = 0x34B5, 877 __DRI_FIXED_RATE_COMPRESSION_3BPC = 0x34B6, 878 __DRI_FIXED_RATE_COMPRESSION_4BPC = 0x34B7, 879 __DRI_FIXED_RATE_COMPRESSION_5BPC = 0x34B8, 880 __DRI_FIXED_RATE_COMPRESSION_6BPC = 0x34B9, 881 __DRI_FIXED_RATE_COMPRESSION_7BPC = 0x34BA, 882 __DRI_FIXED_RATE_COMPRESSION_8BPC = 0x34BB, 883 __DRI_FIXED_RATE_COMPRESSION_9BPC = 0x34BC, 884 __DRI_FIXED_RATE_COMPRESSION_10BPC = 0x34BD, 885 __DRI_FIXED_RATE_COMPRESSION_11BPC = 0x34BE, 886 __DRI_FIXED_RATE_COMPRESSION_12BPC = 0x34BF, 887 }; 888 889 /** 890 * \name Reasons that __DRIimageExtensionRec::createImageFromTexture or 891 * __DRIimageExtensionRec::createImageFromDmaBufs might fail 892 */ 893 /*@{*/ 894 /** Success! */ 895 #define __DRI_IMAGE_ERROR_SUCCESS 0 896 897 /** Memory allocation failure */ 898 #define __DRI_IMAGE_ERROR_BAD_ALLOC 1 899 900 /** Client requested an invalid attribute */ 901 #define __DRI_IMAGE_ERROR_BAD_MATCH 2 902 903 /** Client requested an invalid texture object */ 904 #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3 905 906 /** Client requested an invalid pitch and/or offset */ 907 #define __DRI_IMAGE_ERROR_BAD_ACCESS 4 908 /*@}*/ 909 910 /** 911 * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities 912 */ 913 /*@{*/ 914 #define __DRI_IMAGE_CAP_GLOBAL_NAMES 1 915 /*@}*/ 916 917 /** 918 * blitImage flags 919 */ 920 921 #define __BLIT_FLAG_FLUSH 0x0001 922 #define __BLIT_FLAG_FINISH 0x0002 923 924 /** 925 * Flags for createImageFromDmaBufs 926 */ 927 #define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001 928 #define __DRI_IMAGE_PRIME_LINEAR_BUFFER 0x00000002 929 930 /** 931 * queryDmaBufFormatModifierAttribs attributes 932 */ 933 934 /* Available in version 16 */ 935 #define __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT 0x0001 936 937 typedef struct { 938 __DRIextension base; 939 940 void (*destroyImage)(struct dri_image *image); 941 942 unsigned char (*queryImage)(struct dri_image *image, int attrib, int *value); 943 944 /** 945 * The new struct dri_image will share the content with the old one, see dup(2). 946 */ 947 struct dri_image *(*dupImage)(struct dri_image *image, void *loaderPrivate); 948 949 /** 950 * Validate that a struct dri_image can be used a certain way. 951 * 952 * \since 2 953 */ 954 unsigned char (*validateUsage)(struct dri_image *image, unsigned int use); 955 956 /** 957 * Create an image from a series of GEM names; uses FourCC for format 958 * and byte stride. 959 * 960 * \since 5 961 */ 962 struct dri_image *(*createImageFromNames)(struct dri_screen *screen, 963 int width, int height, int fourcc, 964 int *names, int num_names, 965 int *strides, int *offsets, 966 void *loaderPrivate); 967 968 /** 969 * Create an image out of a sub-region of a parent image. This 970 * entry point lets us create individual dri_image structures for different 971 * planes in a planar buffer (typically yuv), for example. While a 972 * sub-image shares the underlying buffer object with the parent 973 * image and other sibling sub-images, the life times of parent and 974 * sub-images are not dependent. Destroying the parent or a 975 * sub-image doesn't affect other images. The underlying buffer 976 * object is free when no struct dri_image remains that references it. 977 * 978 * Sub-images may overlap, but rendering to overlapping sub-images 979 * is undefined. 980 * 981 * \since 5 982 */ 983 struct dri_image *(*fromPlanar)(struct dri_image *image, int plane, 984 void *loaderPrivate); 985 986 /** 987 * Create image from texture. 988 * 989 * \since 6 990 */ 991 struct dri_image *(*createImageFromTexture)(struct dri_context *context, 992 int target, 993 unsigned texture, 994 int depth, 995 int level, 996 unsigned *error, 997 void *loaderPrivate); 998 999 /** 1000 * Blit a part of a struct dri_image to another and flushes 1001 * 1002 * flush_flag: 1003 * 0: no flush 1004 * __BLIT_FLAG_FLUSH: flush after the blit operation 1005 * __BLIT_FLAG_FINISH: flush and wait the blit finished 1006 * 1007 * \since 9 1008 */ 1009 void (*blitImage)(struct dri_context *context, struct dri_image *dst, struct dri_image *src, 1010 int dstx0, int dsty0, int dstwidth, int dstheight, 1011 int srcx0, int srcy0, int srcwidth, int srcheight, 1012 int flush_flag); 1013 1014 /** 1015 * Query for general capabilities of the driver that concern 1016 * buffer sharing and image importing. 1017 * 1018 * \since 10 1019 */ 1020 int (*getCapabilities)(struct dri_screen *screen); 1021 1022 /** 1023 * Returns a map of the specified region of a struct dri_image for the specified usage. 1024 * 1025 * flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the 1026 * mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ 1027 * is not included in the flags, the buffer content at map time is 1028 * undefined. Users wanting to modify the mapping must include 1029 * __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not 1030 * included, behaviour when writing the mapping is undefined. 1031 * 1032 * Returns the byte stride in *stride, and an opaque pointer to data 1033 * tracking the mapping in **data, which must be passed to unmapImage(). 1034 * 1035 * \since 12 1036 */ 1037 void *(*mapImage)(struct dri_context *context, struct dri_image *image, 1038 int x0, int y0, int width, int height, 1039 unsigned int flags, int *stride, void **data); 1040 1041 /** 1042 * Unmap a previously mapped struct dri_image 1043 * 1044 * \since 12 1045 */ 1046 void (*unmapImage)(struct dri_context *context, struct dri_image *image, void *data); 1047 1048 /* 1049 * dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers. 1050 * 1051 * \param max Maximum number of formats that can be accomodated into 1052 * \param formats. If zero, no formats are returned - 1053 * instead, the driver returns the total number of 1054 * supported dmabuf formats in \param count. 1055 * \param formats Buffer to fill formats into. 1056 * \param count Count of formats returned, or, total number of 1057 * supported formats in case \param max is zero. 1058 * 1059 * Returns true on success. 1060 * 1061 * \since 15 1062 */ 1063 bool (*queryDmaBufFormats)(struct dri_screen *screen, int max, int *formats, 1064 int *count); 1065 1066 /* 1067 * dmabuf format modifier query for a given format to support 1068 * EGL_EXT_image_dma_buf_import_modifiers. 1069 * 1070 * \param fourcc The format to query modifiers for. If this format 1071 * is not supported by the driver, return false. 1072 * \param max Maximum number of modifiers that can be accomodated in 1073 * \param modifiers. If zero, no modifiers are returned - 1074 * instead, the driver returns the total number of 1075 * modifiers for \param format in \param count. 1076 * \param modifiers Buffer to fill modifiers into. 1077 * \param count Count of the modifiers returned, or, total number of 1078 * supported modifiers for \param fourcc in case 1079 * \param max is zero. 1080 * 1081 * Returns true upon success. 1082 * 1083 * \since 15 1084 */ 1085 bool (*queryDmaBufModifiers)(struct dri_screen *screen, int fourcc, int max, 1086 uint64_t *modifiers, 1087 unsigned int *external_only, int *count); 1088 1089 /** 1090 * dmabuf format modifier attribute query for a given format and modifier. 1091 * 1092 * \param fourcc The format to query. If this format is not supported by 1093 * the driver, return false. 1094 * \param modifier The modifier to query. If this format+modifier is not 1095 * supported by the driver, return false. 1096 * \param attrib The __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB to query. 1097 * \param value A pointer to where to store the result of the query. 1098 * 1099 * Returns true upon success. 1100 * 1101 * \since 16 1102 */ 1103 bool (*queryDmaBufFormatModifierAttribs)(struct dri_screen *screen, 1104 uint32_t fourcc, uint64_t modifier, 1105 int attrib, uint64_t *value); 1106 1107 /** 1108 * Create a DRI image from the given renderbuffer. 1109 * 1110 * \param context the current DRI context 1111 * \param renderbuffer the GL name of the renderbuffer 1112 * \param loaderPrivate for callbacks into the loader related to the image 1113 * \param error will be set to one of __DRI_IMAGE_ERROR_xxx 1114 * \return the newly created image on success, or NULL otherwise 1115 */ 1116 struct dri_image *(*createImageFromRenderbuffer)(struct dri_context *context, 1117 int renderbuffer, 1118 void *loaderPrivate, 1119 unsigned *error); 1120 1121 /** 1122 * Creates a DRI image from an array of dmabuf fds and their modifiers. 1123 * 1124 * See __DRI_IMAGE_*_FLAG for valid definitions of flags. 1125 */ 1126 struct dri_image *(*createImageFromDmaBufs)(struct dri_screen *screen, 1127 int width, int height, int fourcc, 1128 uint64_t modifier, 1129 int *fds, int num_fds, 1130 int *strides, int *offsets, 1131 enum __DRIYUVColorSpace color_space, 1132 enum __DRISampleRange sample_range, 1133 enum __DRIChromaSiting horiz_siting, 1134 enum __DRIChromaSiting vert_siting, 1135 uint32_t flags, 1136 unsigned *error, 1137 void *loaderPrivate); 1138 1139 /** 1140 * Creates an image with implementation's favorite modifiers and the 1141 * provided usage flags. 1142 * 1143 * Passing either zero modifiers, or a modifier list consisting only 1144 * of DRM_FORMAT_MOD_INVALID, allows the implementation to select a 1145 * layout with implicit modifiers. 1146 * 1147 * The created image should be destroyed with destroyImage(). 1148 * 1149 * Returns the new DRIimage. The chosen modifier can be obtained later on 1150 * and passed back to things like the kernel's AddFB2 interface. 1151 * 1152 * \since 19 1153 */ 1154 struct dri_image *(*createImage)(struct dri_screen *screen, 1155 int width, int height, int format, 1156 const uint64_t *modifiers, 1157 const unsigned int modifier_count, 1158 unsigned int use, 1159 void *loaderPrivate); 1160 1161 /** 1162 * Set an in-fence-fd on the image. If a fence-fd is already set 1163 * (but not yet consumed), the existing and new fence will be merged 1164 * 1165 * This does *not* take ownership of the fd. The fd does not need 1166 * to be kept alive once the call has returned. 1167 * 1168 * \since 21 1169 */ 1170 void (*setInFenceFd)(struct dri_image *image, int fd); 1171 1172 /* 1173 * Query supported compression rates for a given format for 1174 * EGL_EXT_surface_compression. 1175 * 1176 * \param config Config for which to query the supported compression 1177 * rates. 1178 * \param max Maximum number of rates that can be accomodated into 1179 * \param rates. If zero, no rates are returned - 1180 * instead, the driver returns the total number of 1181 * supported compression rates in \param count. 1182 * \param rates Buffer to fill rates into. 1183 * \param count Count of rates returned, or, total number of 1184 * supported rates in case \param max is zero. 1185 * 1186 * Returns true on success. 1187 * 1188 * \since 22 1189 */ 1190 bool (*queryCompressionRates)(struct dri_screen *screen, const struct dri_config *config, 1191 int max, enum __DRIFixedRateCompression *rates, 1192 int *count); 1193 1194 /* 1195 * Query list of modifiers that are associated with given fixed-rate 1196 * compression bitrate. 1197 * 1198 * \param format The format to query 1199 * \param rate Compression rate to query for 1200 * \param max Maximum number of modifiers that can be accomodated in 1201 * \param modifiers. If zero, no modifiers are returned - 1202 * instead, the driver returns the total number of 1203 * modifiers for \param format in \param count. 1204 * \param modifiers Buffer to fill modifiers into. 1205 * \param count Count of the modifiers returned, or, total number of 1206 * supported modifiers for \param fourcc in case 1207 * \param max is zero. 1208 * 1209 * Returns true on success. 1210 * 1211 * \since 22 1212 */ 1213 bool (*queryCompressionModifiers)(struct dri_screen *screen, uint32_t format, 1214 enum __DRIFixedRateCompression rate, 1215 int max, uint64_t *modifiers, int *count); 1216 } __DRIimageExtension; 1217 1218 1219 /** 1220 * This extension must be implemented by the loader and passed to the 1221 * driver at screen creation time. The EGLImage entry points in the 1222 * various client APIs take opaque EGLImage handles and use this 1223 * extension to map them to a struct dri_image. At version 1, this 1224 * extensions allows mapping EGLImage pointers to struct dri_image pointers, 1225 * but future versions could support other EGLImage-like, opaque types 1226 * with new lookup functions. 1227 */ 1228 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP" 1229 1230 typedef struct { 1231 __DRIextension base; 1232 1233 /** 1234 * Check if EGLImage is associated with the EGL display before lookup with 1235 * lookupEGLImageValidated(). It will hold EGLDisplay.Mutex, so is separated 1236 * out from lookupEGLImageValidated() to avoid deadlock. 1237 */ 1238 unsigned char (*validateEGLImage)(void *image, void *loaderPrivate); 1239 1240 /** 1241 * Lookup EGLImage after validateEGLImage(). No lock in this function. 1242 */ 1243 struct dri_image *(*lookupEGLImageValidated)(void *image, void *loaderPrivate); 1244 } __DRIimageLookupExtension; 1245 1246 /** 1247 * This extension allows for common DRI2 options 1248 */ 1249 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY" 1250 1251 typedef struct { 1252 __DRIextension base; 1253 1254 int (*configQueryb)(struct dri_screen *screen, const char *var, unsigned char *val); 1255 int (*configQueryi)(struct dri_screen *screen, const char *var, int *val); 1256 int (*configQueryf)(struct dri_screen *screen, const char *var, float *val); 1257 int (*configQuerys)(struct dri_screen *screen, const char *var, char **val); 1258 } __DRI2configQueryExtension; 1259 1260 /** 1261 * DRI config options extension. 1262 * 1263 * This extension provides the XML string containing driver options for use by 1264 * the loader in supporting the driconf application. 1265 * 1266 * v2: 1267 * - Add the getXml getter function which allows the driver more flexibility in 1268 * how the XML is provided. 1269 * - Deprecate the direct xml pointer. It is only provided as a fallback for 1270 * older versions of libGL and must not be used by clients that are aware of 1271 * the newer version. Future driver versions may set it to NULL. 1272 */ 1273 #define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions" 1274 1275 typedef struct { 1276 __DRIextension base; 1277 const char *xml; /**< deprecated since v2, use getXml instead */ 1278 1279 /** 1280 * Get an XML string that describes available driver options for use by a 1281 * config application. 1282 * 1283 * The returned string must be heap-allocated. The caller is responsible for 1284 * freeing it. 1285 */ 1286 char *(*getXml)(const char *driver_name); 1287 } __DRIconfigOptionsExtension; 1288 1289 /** 1290 * Query renderer driver extension 1291 * 1292 * This allows the window system layer (either EGL or GLX) to query aspects of 1293 * hardware and driver support without creating a context. 1294 */ 1295 #define __DRI2_RENDERER_VENDOR_ID 0x0000 1296 #define __DRI2_RENDERER_DEVICE_ID 0x0001 1297 #define __DRI2_RENDERER_VERSION 0x0002 1298 #define __DRI2_RENDERER_ACCELERATED 0x0003 1299 #define __DRI2_RENDERER_VIDEO_MEMORY 0x0004 1300 #define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005 1301 #define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006 1302 #define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007 1303 #define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008 1304 #define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009 1305 #define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a 1306 1307 #define __DRI2_RENDERER_PREFER_BACK_BUFFER_REUSE 0x000f 1308 1309 /** 1310 * Image Loader extension. Drivers use this to allocate color buffers 1311 */ 1312 1313 /** 1314 * See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask. 1315 */ 1316 enum __DRIimageBufferMask { 1317 __DRI_IMAGE_BUFFER_BACK = (1 << 0), 1318 __DRI_IMAGE_BUFFER_FRONT = (1 << 1), 1319 1320 /** 1321 * A buffer shared between application and compositor. The buffer may be 1322 * simultaneously accessed by each. 1323 * 1324 * A shared buffer is equivalent to an EGLSurface whose EGLConfig contains 1325 * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as 1326 * opposed to any pending, requested change to EGL_RENDER_BUFFER) is 1327 * EGL_SINGLE_BUFFER. 1328 * 1329 * If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no 1330 * other bits. As a corollary, a struct dri_drawable that has a "shared" buffer 1331 * has no front nor back buffer. 1332 * 1333 * The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only 1334 * if: 1335 * - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER. 1336 * - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER. 1337 * - The EGLConfig of the drawable EGLSurface contains 1338 * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR. 1339 * - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER. 1340 * Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as 1341 * opposed to any pending, requested change to EGL_RENDER_BUFFER) is 1342 * EGL_SINGLE_BUFFER. (See the EGL 1.5 and 1343 * EGL_KHR_mutable_render_buffer spec for details about "pending" vs 1344 * "active" EGL_RENDER_BUFFER state). 1345 * 1346 * A shared buffer is similar to a front buffer in that all rendering to the 1347 * buffer should appear promptly on the screen. It is different from 1348 * a front buffer in that its behavior is independent from the 1349 * GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the 1350 * struct dri_drawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all 1351 * rendering should appear promptly on the screen if GL_DRAW_BUFFER is not 1352 * GL_NONE. 1353 * 1354 * The difference between a shared buffer and a front buffer is motivated 1355 * by the constraints of Android and OpenGL ES. OpenGL ES does not support 1356 * front-buffer rendering. Android's SurfaceFlinger protocol provides the 1357 * EGL driver only a back buffer and no front buffer. The shared buffer 1358 * mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though 1359 * EGL that allows Android OpenGL ES applications to render to what is 1360 * effectively the front buffer, a backdoor that required no change to the 1361 * OpenGL ES API and little change to the SurfaceFlinger API. 1362 */ 1363 __DRI_IMAGE_BUFFER_SHARED = (1 << 2), 1364 }; 1365 1366 struct __DRIimageList { 1367 uint32_t image_mask; 1368 struct dri_image *back; 1369 struct dri_image *front; 1370 }; 1371 1372 #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER" 1373 1374 typedef struct { 1375 __DRIextension base; 1376 1377 /** 1378 * Allocate color buffers. 1379 * 1380 * \param driDrawable 1381 * \param width Width of allocated buffers 1382 * \param height Height of allocated buffers 1383 * \param format one of __DRI_IMAGE_FORMAT_* 1384 * \param stamp Address of variable to be updated when 1385 * getBuffers must be called again 1386 * \param loaderPrivate The loaderPrivate for driDrawable 1387 * \param buffer_mask Set of buffers to allocate. A bitmask of 1388 * __DRIimageBufferMask. 1389 * \param buffers Returned buffers 1390 */ 1391 int (*getBuffers)(struct dri_drawable *driDrawable, 1392 unsigned int format, 1393 uint32_t *stamp, 1394 void *loaderPrivate, 1395 uint32_t buffer_mask, 1396 struct __DRIimageList *buffers); 1397 1398 /** 1399 * Flush pending front-buffer rendering 1400 * 1401 * Any rendering that has been performed to the 1402 * fake front will be flushed to the front 1403 * 1404 * \param driDrawable Drawable whose front-buffer is to be flushed 1405 * \param loaderPrivate Loader's private data 1406 */ 1407 void (*flushFrontBuffer)(struct dri_drawable *driDrawable, void *loaderPrivate); 1408 1409 /** 1410 * Return a loader capability value. If the loader doesn't know the enum, 1411 * it will return 0. 1412 * 1413 * \since 2 1414 */ 1415 unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap); 1416 1417 /** 1418 * Flush swap buffers 1419 * 1420 * Make sure any outstanding swap buffers have been submitted to the 1421 * device. 1422 * 1423 * \param driDrawable Drawable whose swaps need to be flushed 1424 * \param loaderPrivate Loader's private data 1425 * 1426 * \since 3 1427 */ 1428 void (*flushSwapBuffers)(struct dri_drawable *driDrawable, void *loaderPrivate); 1429 1430 /** 1431 * Clean up any loader state associated with an image. 1432 * 1433 * \param loaderPrivate Loader's private data that was previously passed 1434 * into a __DRIimageExtensionRec::createImage function 1435 * \since 4 1436 */ 1437 void (*destroyLoaderImageState)(void *loaderPrivate); 1438 } __DRIimageLoaderExtension; 1439 1440 /** 1441 * Main DRI3 interface extension. 1442 * 1443 * Not used by the X server. 1444 */ 1445 1446 typedef struct { 1447 __DRIextension base; 1448 1449 /* Common DRI functions, shared with DRI2 */ 1450 __DRIcreateNewScreen2Func createNewScreen2; 1451 __DRIcreateNewDrawableFunc createNewDrawable; 1452 __DRIcreateContextAttribsFunc createContextAttribs; 1453 __DRIgetAPIMaskFunc getAPIMask; 1454 __DRIcreateNewScreen3Func createNewScreen3; 1455 } __DRIimageDriverExtension; 1456 1457 /** 1458 * Background callable loader extension. 1459 * 1460 * Loaders expose this extension to indicate to drivers that they are capable 1461 * of handling callbacks from the driver's background drawing threads. 1462 */ 1463 #define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable" 1464 1465 typedef struct { 1466 __DRIextension base; 1467 1468 /** 1469 * Indicate that this thread is being used by the driver as a background 1470 * drawing thread which may make callbacks to the loader. 1471 * 1472 * \param loaderPrivate is the value that was passed to to the driver when 1473 * the context was created. This can be used by the loader to identify 1474 * which context any callbacks are associated with. 1475 * 1476 * If this function is called more than once from any given thread, each 1477 * subsequent call overrides the loaderPrivate data that was passed in the 1478 * previous call. The driver can take advantage of this to re-use a 1479 * background thread to perform drawing on behalf of multiple contexts. 1480 * 1481 * It is permissible for the driver to call this function from a 1482 * non-background thread (i.e. a thread that has already been bound to a 1483 * context using __DRIcoreExtension::bindContext()); when this happens, 1484 * the \c loaderPrivate pointer must be equal to the pointer that was 1485 * passed to the driver when the currently bound context was created. 1486 * 1487 * This call should execute quickly enough that the driver can call it with 1488 * impunity whenever a background thread starts performing drawing 1489 * operations (e.g. it should just set a thread-local variable). 1490 */ 1491 void (*setBackgroundContext)(void *loaderPrivate); 1492 1493 /** 1494 * Indicate that it is multithread safe to use glthread. For GLX/EGL 1495 * platforms using Xlib, that involves calling XInitThreads, before 1496 * opening an X display. 1497 * 1498 * Note: only supported if extension version is at least 2. 1499 * 1500 * \param loaderPrivate is the value that was passed to to the driver when 1501 * the context was created. This can be used by the loader to identify 1502 * which context any callbacks are associated with. 1503 */ 1504 unsigned char (*isThreadSafe)(void *loaderPrivate); 1505 } __DRIbackgroundCallableExtension; 1506 1507 /** 1508 * The loader portion of EGL_KHR_mutable_render_buffer. 1509 * 1510 * Requires loader extension DRI_IMAGE_LOADER, through which the loader sends 1511 * __DRI_IMAGE_BUFFER_SHARED to the driver. 1512 * 1513 * Not used by the X server. 1514 * 1515 * \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER 1516 */ 1517 #define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader" 1518 1519 typedef struct { 1520 __DRIextension base; 1521 1522 /** 1523 * Inform the display engine (that is, SurfaceFlinger and/or hwcomposer) 1524 * that the struct dri_drawable has new content. 1525 * 1526 * The display engine may ignore this call, for example, if it continually 1527 * refreshes and displays the buffer on every frame, as in 1528 * EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display 1529 * engine may refresh and display the buffer only in frames in which the 1530 * driver calls this. 1531 * 1532 * If the fence_fd is not -1, then the display engine will display the 1533 * buffer only after the fence signals. 1534 * 1535 * The drawable's current __DRIimageBufferMask, as returned by 1536 * __DRIimageLoaderExtension::getBuffers(), must be 1537 * __DRI_IMAGE_BUFFER_SHARED. 1538 */ 1539 void (*displaySharedBuffer)(struct dri_drawable *drawable, int fence_fd, 1540 void *loaderPrivate); 1541 } __DRImutableRenderBufferLoaderExtension; 1542 1543 /* Mesa-internal interface between the GLX, GBM, and EGL DRI driver loaders, and 1544 * the gallium dri_util.c code. 1545 */ 1546 1547 #define __DRI_MESA "DRI_Mesa" 1548 1549 /** Core struct that appears alongside __DRI_CORE for Mesa-internal usage. 1550 * Implemented in the top-level dri/drisw/kopper extension list. 1551 */ 1552 typedef struct { 1553 __DRIextension base; 1554 1555 /* Version string for verifying that the DRI driver is from the same build as 1556 * the loader. 1557 */ 1558 #define MESA_INTERFACE_VERSION_STRING PACKAGE_VERSION MESA_GIT_SHA1 1559 const char *version_string; 1560 1561 1562 __DRIcreateContextAttribsFunc createContext; 1563 1564 /* driver function for finishing initialization inside createNewScreen(). */ 1565 const struct dri_config **(*initScreen)(struct dri_screen *screen, bool driver_name_is_inferred); 1566 1567 int (*queryCompatibleRenderOnlyDeviceFd)(int kms_only_fd); 1568 1569 /* Screen creation function regardless of DRI2, image, or swrast backend. 1570 * (Nothing uses the old __DRI_CORE screen create). 1571 * 1572 * If not associated with a DRM fd (non-swkms swrast), the fd argument should 1573 * be -1. 1574 */ 1575 /* version 2 */ 1576 __DRIcreateNewScreen3Func createNewScreen3; 1577 } __DRImesaCoreExtension; 1578 1579 #endif /* MESA_INTERFACE_H */ 1580