dri_interface.h revision af69d88d
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/* For archs with no drm.h */ 44#if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__) 45#ifndef __NOT_HAVE_DRM_H 46#define __NOT_HAVE_DRM_H 47#endif 48#endif 49 50#ifndef __NOT_HAVE_DRM_H 51#include <drm.h> 52#else 53typedef unsigned int drm_context_t; 54typedef unsigned int drm_drawable_t; 55typedef struct drm_clip_rect drm_clip_rect_t; 56#endif 57 58/** 59 * \name DRI interface structures 60 * 61 * The following structures define the interface between the GLX client 62 * side library and the DRI (direct rendering infrastructure). 63 */ 64/*@{*/ 65typedef struct __DRIdisplayRec __DRIdisplay; 66typedef struct __DRIscreenRec __DRIscreen; 67typedef struct __DRIcontextRec __DRIcontext; 68typedef struct __DRIdrawableRec __DRIdrawable; 69typedef struct __DRIconfigRec __DRIconfig; 70typedef struct __DRIframebufferRec __DRIframebuffer; 71typedef struct __DRIversionRec __DRIversion; 72 73typedef struct __DRIcoreExtensionRec __DRIcoreExtension; 74typedef struct __DRIextensionRec __DRIextension; 75typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension; 76typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension; 77typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension; 78typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension; 79typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension; 80typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension; 81typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension; 82typedef struct __DRIswrastExtensionRec __DRIswrastExtension; 83typedef struct __DRIbufferRec __DRIbuffer; 84typedef struct __DRIdri2ExtensionRec __DRIdri2Extension; 85typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension; 86typedef struct __DRI2flushExtensionRec __DRI2flushExtension; 87typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension; 88 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_MESA_swap_frame_usage extension. 158 */ 159#define __DRI_FRAME_TRACKING "DRI_FrameTracking" 160#define __DRI_FRAME_TRACKING_VERSION 1 161struct __DRIframeTrackingExtensionRec { 162 __DRIextension base; 163 164 /** 165 * Enable or disable frame usage tracking. 166 * 167 * \since Internal API version 20030317. 168 */ 169 int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable); 170 171 /** 172 * Retrieve frame usage information. 173 * 174 * \since Internal API version 20030317. 175 */ 176 int (*queryFrameTracking)(__DRIdrawable *drawable, 177 int64_t * sbc, int64_t * missedFrames, 178 float * lastMissedUsage, float * usage); 179}; 180 181 182/** 183 * Used by drivers that implement the GLX_SGI_video_sync extension. 184 */ 185#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter" 186#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1 187struct __DRImediaStreamCounterExtensionRec { 188 __DRIextension base; 189 190 /** 191 * Wait for the MSC to equal target_msc, or, if that has already passed, 192 * the next time (MSC % divisor) is equal to remainder. If divisor is 193 * zero, the function will return as soon as MSC is greater than or equal 194 * to target_msc. 195 */ 196 int (*waitForMSC)(__DRIdrawable *drawable, 197 int64_t target_msc, int64_t divisor, int64_t remainder, 198 int64_t * msc, int64_t * sbc); 199 200 /** 201 * Get the number of vertical refreshes since some point in time before 202 * this function was first called (i.e., system start up). 203 */ 204 int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable, 205 int64_t *msc); 206}; 207 208 209#define __DRI_TEX_OFFSET "DRI_TexOffset" 210#define __DRI_TEX_OFFSET_VERSION 1 211struct __DRItexOffsetExtensionRec { 212 __DRIextension base; 213 214 /** 215 * Method to override base texture image with a driver specific 'offset'. 216 * The depth passed in allows e.g. to ignore the alpha channel of texture 217 * images where the non-alpha components don't occupy a whole texel. 218 * 219 * For GLX_EXT_texture_from_pixmap with AIGLX. 220 */ 221 void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname, 222 unsigned long long offset, GLint depth, GLuint pitch); 223}; 224 225 226/* Valid values for format in the setTexBuffer2 function below. These 227 * values match the GLX tokens for compatibility reasons, but we 228 * define them here since the DRI interface can't depend on GLX. */ 229#define __DRI_TEXTURE_FORMAT_NONE 0x20D8 230#define __DRI_TEXTURE_FORMAT_RGB 0x20D9 231#define __DRI_TEXTURE_FORMAT_RGBA 0x20DA 232 233#define __DRI_TEX_BUFFER "DRI_TexBuffer" 234#define __DRI_TEX_BUFFER_VERSION 3 235struct __DRItexBufferExtensionRec { 236 __DRIextension base; 237 238 /** 239 * Method to override base texture image with the contents of a 240 * __DRIdrawable. 241 * 242 * For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of 243 * setTexBuffer2 in version 2 of this interface 244 */ 245 void (*setTexBuffer)(__DRIcontext *pDRICtx, 246 GLint target, 247 __DRIdrawable *pDraw); 248 249 /** 250 * Method to override base texture image with the contents of a 251 * __DRIdrawable, including the required texture format attribute. 252 * 253 * For GLX_EXT_texture_from_pixmap with AIGLX. 254 * 255 * \since 2 256 */ 257 void (*setTexBuffer2)(__DRIcontext *pDRICtx, 258 GLint target, 259 GLint format, 260 __DRIdrawable *pDraw); 261 /** 262 * Method to release texture buffer in case some special platform 263 * need this. 264 * 265 * For GLX_EXT_texture_from_pixmap with AIGLX. 266 * 267 * \since 3 268 */ 269 void (*releaseTexBuffer)(__DRIcontext *pDRICtx, 270 GLint target, 271 __DRIdrawable *pDraw); 272}; 273 274/** 275 * Used by drivers that implement DRI2 276 */ 277#define __DRI2_FLUSH "DRI2_Flush" 278#define __DRI2_FLUSH_VERSION 4 279 280#define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */ 281#define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */ 282 283enum __DRI2throttleReason { 284 __DRI2_THROTTLE_SWAPBUFFER, 285 __DRI2_THROTTLE_COPYSUBBUFFER, 286 __DRI2_THROTTLE_FLUSHFRONT 287}; 288 289struct __DRI2flushExtensionRec { 290 __DRIextension base; 291 void (*flush)(__DRIdrawable *drawable); 292 293 /** 294 * Ask the driver to call getBuffers/getBuffersWithFormat before 295 * it starts rendering again. 296 * 297 * \param drawable the drawable to invalidate 298 * 299 * \since 3 300 */ 301 void (*invalidate)(__DRIdrawable *drawable); 302 303 /** 304 * This function reduces the number of flushes in the driver by combining 305 * several operations into one call. 306 * 307 * It can: 308 * - throttle 309 * - flush a drawable 310 * - flush a context 311 * 312 * \param context the context 313 * \param drawable the drawable to flush 314 * \param flags a combination of _DRI2_FLUSH_xxx flags 315 * \param throttle_reason the reason for throttling, 0 = no throttling 316 * 317 * \since 4 318 */ 319 void (*flush_with_flags)(__DRIcontext *ctx, 320 __DRIdrawable *drawable, 321 unsigned flags, 322 enum __DRI2throttleReason throttle_reason); 323}; 324 325 326/** 327 * Extension that the driver uses to request 328 * throttle callbacks. 329 */ 330 331#define __DRI2_THROTTLE "DRI2_Throttle" 332#define __DRI2_THROTTLE_VERSION 1 333 334struct __DRI2throttleExtensionRec { 335 __DRIextension base; 336 void (*throttle)(__DRIcontext *ctx, 337 __DRIdrawable *drawable, 338 enum __DRI2throttleReason reason); 339}; 340 341/*@}*/ 342 343/** 344 * The following extensions describe loader features that the DRI 345 * driver can make use of. Some of these are mandatory, such as the 346 * getDrawableInfo extension for DRI and the DRI Loader extensions for 347 * DRI2, while others are optional, and if present allow the driver to 348 * expose certain features. The loader pass in a NULL terminated 349 * array of these extensions to the driver in the createNewScreen 350 * constructor. 351 */ 352 353typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension; 354typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension; 355typedef struct __DRIdamageExtensionRec __DRIdamageExtension; 356typedef struct __DRIloaderExtensionRec __DRIloaderExtension; 357typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension; 358 359 360/** 361 * Callback to getDrawableInfo protocol 362 */ 363#define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo" 364#define __DRI_GET_DRAWABLE_INFO_VERSION 1 365struct __DRIgetDrawableInfoExtensionRec { 366 __DRIextension base; 367 368 /** 369 * This function is used to get information about the position, size, and 370 * clip rects of a drawable. 371 */ 372 GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable, 373 unsigned int * index, unsigned int * stamp, 374 int * x, int * y, int * width, int * height, 375 int * numClipRects, drm_clip_rect_t ** pClipRects, 376 int * backX, int * backY, 377 int * numBackClipRects, drm_clip_rect_t ** pBackClipRects, 378 void *loaderPrivate); 379}; 380 381/** 382 * Callback to get system time for media stream counter extensions. 383 */ 384#define __DRI_SYSTEM_TIME "DRI_SystemTime" 385#define __DRI_SYSTEM_TIME_VERSION 1 386struct __DRIsystemTimeExtensionRec { 387 __DRIextension base; 388 389 /** 390 * Get the 64-bit unadjusted system time (UST). 391 */ 392 int (*getUST)(int64_t * ust); 393 394 /** 395 * Get the media stream counter (MSC) rate. 396 * 397 * Matching the definition in GLX_OML_sync_control, this function returns 398 * the rate of the "media stream counter". In practical terms, this is 399 * the frame refresh rate of the display. 400 */ 401 GLboolean (*getMSCRate)(__DRIdrawable *draw, 402 int32_t * numerator, int32_t * denominator, 403 void *loaderPrivate); 404}; 405 406/** 407 * Damage reporting 408 */ 409#define __DRI_DAMAGE "DRI_Damage" 410#define __DRI_DAMAGE_VERSION 1 411struct __DRIdamageExtensionRec { 412 __DRIextension base; 413 414 /** 415 * Reports areas of the given drawable which have been modified by the 416 * driver. 417 * 418 * \param drawable which the drawing was done to. 419 * \param rects rectangles affected, with the drawable origin as the 420 * origin. 421 * \param x X offset of the drawable within the screen (used in the 422 * front_buffer case) 423 * \param y Y offset of the drawable within the screen. 424 * \param front_buffer boolean flag for whether the drawing to the 425 * drawable was actually done directly to the front buffer (instead 426 * of backing storage, for example) 427 * \param loaderPrivate the data passed in at createNewDrawable time 428 */ 429 void (*reportDamage)(__DRIdrawable *draw, 430 int x, int y, 431 drm_clip_rect_t *rects, int num_rects, 432 GLboolean front_buffer, 433 void *loaderPrivate); 434}; 435 436#define __DRI_SWRAST_IMAGE_OP_DRAW 1 437#define __DRI_SWRAST_IMAGE_OP_CLEAR 2 438#define __DRI_SWRAST_IMAGE_OP_SWAP 3 439 440/** 441 * SWRast Loader extension. 442 */ 443#define __DRI_SWRAST_LOADER "DRI_SWRastLoader" 444#define __DRI_SWRAST_LOADER_VERSION 2 445struct __DRIswrastLoaderExtensionRec { 446 __DRIextension base; 447 448 /* 449 * Drawable position and size 450 */ 451 void (*getDrawableInfo)(__DRIdrawable *drawable, 452 int *x, int *y, int *width, int *height, 453 void *loaderPrivate); 454 455 /** 456 * Put image to drawable 457 */ 458 void (*putImage)(__DRIdrawable *drawable, int op, 459 int x, int y, int width, int height, 460 char *data, void *loaderPrivate); 461 462 /** 463 * Get image from readable 464 */ 465 void (*getImage)(__DRIdrawable *readable, 466 int x, int y, int width, int height, 467 char *data, void *loaderPrivate); 468 469 /** 470 * Put image to drawable 471 * 472 * \since 2 473 */ 474 void (*putImage2)(__DRIdrawable *drawable, int op, 475 int x, int y, int width, int height, int stride, 476 char *data, void *loaderPrivate); 477}; 478 479/** 480 * Invalidate loader extension. The presence of this extension 481 * indicates to the DRI driver that the loader will call invalidate in 482 * the __DRI2_FLUSH extension, whenever the needs to query for new 483 * buffers. This means that the DRI driver can drop the polling in 484 * glViewport(). 485 * 486 * The extension doesn't provide any functionality, it's only use to 487 * indicate to the driver that it can use the new semantics. A DRI 488 * driver can use this to switch between the different semantics or 489 * just refuse to initialize if this extension isn't present. 490 */ 491#define __DRI_USE_INVALIDATE "DRI_UseInvalidate" 492#define __DRI_USE_INVALIDATE_VERSION 1 493 494typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension; 495struct __DRIuseInvalidateExtensionRec { 496 __DRIextension base; 497}; 498 499/** 500 * The remaining extensions describe driver extensions, immediately 501 * available interfaces provided by the driver. To start using the 502 * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for 503 * the extension you need in the array. 504 */ 505#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions" 506 507/** 508 * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be 509 * suffixed by "_drivername", allowing multiple drivers to be built into one 510 * library, and also giving the driver the chance to return a variable driver 511 * extensions struct depending on the driver name being loaded or any other 512 * system state. 513 * 514 * The function prototype is: 515 * 516 * const __DRIextension **__driDriverGetExtensions_drivername(void); 517 */ 518#define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions" 519 520/** 521 * Tokens for __DRIconfig attribs. A number of attributes defined by 522 * GLX or EGL standards are not in the table, as they must be provided 523 * by the loader. For example, FBConfig ID or visual ID, drawable type. 524 */ 525 526#define __DRI_ATTRIB_BUFFER_SIZE 1 527#define __DRI_ATTRIB_LEVEL 2 528#define __DRI_ATTRIB_RED_SIZE 3 529#define __DRI_ATTRIB_GREEN_SIZE 4 530#define __DRI_ATTRIB_BLUE_SIZE 5 531#define __DRI_ATTRIB_LUMINANCE_SIZE 6 532#define __DRI_ATTRIB_ALPHA_SIZE 7 533#define __DRI_ATTRIB_ALPHA_MASK_SIZE 8 534#define __DRI_ATTRIB_DEPTH_SIZE 9 535#define __DRI_ATTRIB_STENCIL_SIZE 10 536#define __DRI_ATTRIB_ACCUM_RED_SIZE 11 537#define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12 538#define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13 539#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14 540#define __DRI_ATTRIB_SAMPLE_BUFFERS 15 541#define __DRI_ATTRIB_SAMPLES 16 542#define __DRI_ATTRIB_RENDER_TYPE 17 543#define __DRI_ATTRIB_CONFIG_CAVEAT 18 544#define __DRI_ATTRIB_CONFORMANT 19 545#define __DRI_ATTRIB_DOUBLE_BUFFER 20 546#define __DRI_ATTRIB_STEREO 21 547#define __DRI_ATTRIB_AUX_BUFFERS 22 548#define __DRI_ATTRIB_TRANSPARENT_TYPE 23 549#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24 550#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25 551#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26 552#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27 553#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28 554#define __DRI_ATTRIB_FLOAT_MODE 29 555#define __DRI_ATTRIB_RED_MASK 30 556#define __DRI_ATTRIB_GREEN_MASK 31 557#define __DRI_ATTRIB_BLUE_MASK 32 558#define __DRI_ATTRIB_ALPHA_MASK 33 559#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34 560#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35 561#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36 562#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37 563#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38 564#define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39 565#define __DRI_ATTRIB_SWAP_METHOD 40 566#define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41 567#define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42 568#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43 569#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44 570#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45 571#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46 572#define __DRI_ATTRIB_YINVERTED 47 573#define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48 574 575/* __DRI_ATTRIB_RENDER_TYPE */ 576#define __DRI_ATTRIB_RGBA_BIT 0x01 577#define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02 578#define __DRI_ATTRIB_LUMINANCE_BIT 0x04 579#define __DRI_ATTRIB_FLOAT_BIT 0x08 580#define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10 581 582/* __DRI_ATTRIB_CONFIG_CAVEAT */ 583#define __DRI_ATTRIB_SLOW_BIT 0x01 584#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02 585 586/* __DRI_ATTRIB_TRANSPARENT_TYPE */ 587#define __DRI_ATTRIB_TRANSPARENT_RGB 0x00 588#define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01 589 590/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */ 591#define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01 592#define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02 593#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04 594 595/** 596 * This extension defines the core DRI functionality. 597 */ 598#define __DRI_CORE "DRI_Core" 599#define __DRI_CORE_VERSION 1 600 601struct __DRIcoreExtensionRec { 602 __DRIextension base; 603 604 __DRIscreen *(*createNewScreen)(int screen, int fd, 605 unsigned int sarea_handle, 606 const __DRIextension **extensions, 607 const __DRIconfig ***driverConfigs, 608 void *loaderPrivate); 609 610 void (*destroyScreen)(__DRIscreen *screen); 611 612 const __DRIextension **(*getExtensions)(__DRIscreen *screen); 613 614 int (*getConfigAttrib)(const __DRIconfig *config, 615 unsigned int attrib, 616 unsigned int *value); 617 618 int (*indexConfigAttrib)(const __DRIconfig *config, int index, 619 unsigned int *attrib, unsigned int *value); 620 621 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen, 622 const __DRIconfig *config, 623 unsigned int drawable_id, 624 unsigned int head, 625 void *loaderPrivate); 626 627 void (*destroyDrawable)(__DRIdrawable *drawable); 628 629 void (*swapBuffers)(__DRIdrawable *drawable); 630 631 __DRIcontext *(*createNewContext)(__DRIscreen *screen, 632 const __DRIconfig *config, 633 __DRIcontext *shared, 634 void *loaderPrivate); 635 636 int (*copyContext)(__DRIcontext *dest, 637 __DRIcontext *src, 638 unsigned long mask); 639 640 void (*destroyContext)(__DRIcontext *context); 641 642 int (*bindContext)(__DRIcontext *ctx, 643 __DRIdrawable *pdraw, 644 __DRIdrawable *pread); 645 646 int (*unbindContext)(__DRIcontext *ctx); 647}; 648 649/** 650 * Stored version of some component (i.e., server-side DRI module, kernel-side 651 * DRM, etc.). 652 * 653 * \todo 654 * There are several data structures that explicitly store a major version, 655 * minor version, and patch level. These structures should be modified to 656 * have a \c __DRIversionRec instead. 657 */ 658struct __DRIversionRec { 659 int major; /**< Major version number. */ 660 int minor; /**< Minor version number. */ 661 int patch; /**< Patch-level. */ 662}; 663 664/** 665 * Framebuffer information record. Used by libGL to communicate information 666 * about the framebuffer to the driver's \c __driCreateNewScreen function. 667 * 668 * In XFree86, most of this information is derrived from data returned by 669 * calling \c XF86DRIGetDeviceInfo. 670 * 671 * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen 672 * __driUtilCreateNewScreen CallCreateNewScreen 673 * 674 * \bug This structure could be better named. 675 */ 676struct __DRIframebufferRec { 677 unsigned char *base; /**< Framebuffer base address in the CPU's 678 * address space. This value is calculated by 679 * calling \c drmMap on the framebuffer handle 680 * returned by \c XF86DRIGetDeviceInfo (or a 681 * similar function). 682 */ 683 int size; /**< Framebuffer size, in bytes. */ 684 int stride; /**< Number of bytes from one line to the next. */ 685 int width; /**< Pixel width of the framebuffer. */ 686 int height; /**< Pixel height of the framebuffer. */ 687 int dev_priv_size; /**< Size of the driver's dev-priv structure. */ 688 void *dev_priv; /**< Pointer to the driver's dev-priv structure. */ 689}; 690 691 692/** 693 * This extension provides alternative screen, drawable and context 694 * constructors for legacy DRI functionality. This is used in 695 * conjunction with the core extension. 696 */ 697#define __DRI_LEGACY "DRI_Legacy" 698#define __DRI_LEGACY_VERSION 1 699 700struct __DRIlegacyExtensionRec { 701 __DRIextension base; 702 703 __DRIscreen *(*createNewScreen)(int screen, 704 const __DRIversion *ddx_version, 705 const __DRIversion *dri_version, 706 const __DRIversion *drm_version, 707 const __DRIframebuffer *frame_buffer, 708 void *pSAREA, int fd, 709 const __DRIextension **extensions, 710 const __DRIconfig ***driver_configs, 711 void *loaderPrivate); 712 713 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen, 714 const __DRIconfig *config, 715 drm_drawable_t hwDrawable, 716 int renderType, const int *attrs, 717 void *loaderPrivate); 718 719 __DRIcontext *(*createNewContext)(__DRIscreen *screen, 720 const __DRIconfig *config, 721 int render_type, 722 __DRIcontext *shared, 723 drm_context_t hwContext, 724 void *loaderPrivate); 725}; 726 727/** 728 * This extension provides alternative screen, drawable and context 729 * constructors for swrast DRI functionality. This is used in 730 * conjunction with the core extension. 731 */ 732#define __DRI_SWRAST "DRI_SWRast" 733#define __DRI_SWRAST_VERSION 4 734 735struct __DRIswrastExtensionRec { 736 __DRIextension base; 737 738 __DRIscreen *(*createNewScreen)(int screen, 739 const __DRIextension **extensions, 740 const __DRIconfig ***driver_configs, 741 void *loaderPrivate); 742 743 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen, 744 const __DRIconfig *config, 745 void *loaderPrivate); 746 747 /* Since version 2 */ 748 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen, 749 int api, 750 const __DRIconfig *config, 751 __DRIcontext *shared, 752 void *data); 753 754 /** 755 * Create a context for a particular API with a set of attributes 756 * 757 * \since version 3 758 * 759 * \sa __DRIdri2ExtensionRec::createContextAttribs 760 */ 761 __DRIcontext *(*createContextAttribs)(__DRIscreen *screen, 762 int api, 763 const __DRIconfig *config, 764 __DRIcontext *shared, 765 unsigned num_attribs, 766 const uint32_t *attribs, 767 unsigned *error, 768 void *loaderPrivate); 769 770 /** 771 * createNewScreen() with the driver extensions passed in. 772 * 773 * \since version 4 774 */ 775 __DRIscreen *(*createNewScreen2)(int screen, 776 const __DRIextension **loader_extensions, 777 const __DRIextension **driver_extensions, 778 const __DRIconfig ***driver_configs, 779 void *loaderPrivate); 780 781}; 782 783/** Common DRI function definitions, shared among DRI2 and Image extensions 784 */ 785 786typedef __DRIscreen * 787(*__DRIcreateNewScreen2Func)(int screen, int fd, 788 const __DRIextension **extensions, 789 const __DRIextension **driver_extensions, 790 const __DRIconfig ***driver_configs, 791 void *loaderPrivate); 792 793typedef __DRIdrawable * 794(*__DRIcreateNewDrawableFunc)(__DRIscreen *screen, 795 const __DRIconfig *config, 796 void *loaderPrivate); 797 798typedef __DRIcontext * 799(*__DRIcreateContextAttribsFunc)(__DRIscreen *screen, 800 int api, 801 const __DRIconfig *config, 802 __DRIcontext *shared, 803 unsigned num_attribs, 804 const uint32_t *attribs, 805 unsigned *error, 806 void *loaderPrivate); 807 808typedef unsigned int 809(*__DRIgetAPIMaskFunc)(__DRIscreen *screen); 810 811/** 812 * DRI2 Loader extension. 813 */ 814#define __DRI_BUFFER_FRONT_LEFT 0 815#define __DRI_BUFFER_BACK_LEFT 1 816#define __DRI_BUFFER_FRONT_RIGHT 2 817#define __DRI_BUFFER_BACK_RIGHT 3 818#define __DRI_BUFFER_DEPTH 4 819#define __DRI_BUFFER_STENCIL 5 820#define __DRI_BUFFER_ACCUM 6 821#define __DRI_BUFFER_FAKE_FRONT_LEFT 7 822#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8 823#define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */ 824#define __DRI_BUFFER_HIZ 10 825 826/* Inofficial and for internal use. Increase when adding a new buffer token. */ 827#define __DRI_BUFFER_COUNT 11 828 829struct __DRIbufferRec { 830 unsigned int attachment; 831 unsigned int name; 832 unsigned int pitch; 833 unsigned int cpp; 834 unsigned int flags; 835}; 836 837#define __DRI_DRI2_LOADER "DRI_DRI2Loader" 838#define __DRI_DRI2_LOADER_VERSION 3 839struct __DRIdri2LoaderExtensionRec { 840 __DRIextension base; 841 842 __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable, 843 int *width, int *height, 844 unsigned int *attachments, int count, 845 int *out_count, void *loaderPrivate); 846 847 /** 848 * Flush pending front-buffer rendering 849 * 850 * Any rendering that has been performed to the 851 * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the 852 * \c __DRI_BUFFER_FRONT_LEFT. 853 * 854 * \param driDrawable Drawable whose front-buffer is to be flushed 855 * \param loaderPrivate Loader's private data that was previously passed 856 * into __DRIdri2ExtensionRec::createNewDrawable 857 * 858 * \since 2 859 */ 860 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate); 861 862 863 /** 864 * Get list of buffers from the server 865 * 866 * Gets a list of buffer for the specified set of attachments. Unlike 867 * \c ::getBuffers, this function takes a list of attachments paired with 868 * opaque \c unsigned \c int value describing the format of the buffer. 869 * It is the responsibility of the caller to know what the service that 870 * allocates the buffers will expect to receive for the format. 871 * 872 * \param driDrawable Drawable whose buffers are being queried. 873 * \param width Output where the width of the buffers is stored. 874 * \param height Output where the height of the buffers is stored. 875 * \param attachments List of pairs of attachment ID and opaque format 876 * requested for the drawable. 877 * \param count Number of attachment / format pairs stored in 878 * \c attachments. 879 * \param loaderPrivate Loader's private data that was previously passed 880 * into __DRIdri2ExtensionRec::createNewDrawable. 881 * 882 * \since 3 883 */ 884 __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable, 885 int *width, int *height, 886 unsigned int *attachments, int count, 887 int *out_count, void *loaderPrivate); 888}; 889 890/** 891 * This extension provides alternative screen, drawable and context 892 * constructors for DRI2. 893 */ 894#define __DRI_DRI2 "DRI_DRI2" 895#define __DRI_DRI2_VERSION 4 896 897#define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */ 898#define __DRI_API_GLES 1 /**< OpenGL ES 1.x */ 899#define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */ 900#define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */ 901#define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */ 902 903#define __DRI_CTX_ATTRIB_MAJOR_VERSION 0 904#define __DRI_CTX_ATTRIB_MINOR_VERSION 1 905#define __DRI_CTX_ATTRIB_FLAGS 2 906 907/** 908 * \requires __DRI2_ROBUSTNESS. 909 */ 910#define __DRI_CTX_ATTRIB_RESET_STRATEGY 3 911 912#define __DRI_CTX_FLAG_DEBUG 0x00000001 913#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002 914 915/** 916 * \requires __DRI2_ROBUSTNESS. 917 */ 918#define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004 919 920/** 921 * \name Context reset strategies. 922 */ 923/*@{*/ 924#define __DRI_CTX_RESET_NO_NOTIFICATION 0 925#define __DRI_CTX_RESET_LOSE_CONTEXT 1 926/*@}*/ 927 928/** 929 * \name Reasons that __DRIdri2Extension::createContextAttribs might fail 930 */ 931/*@{*/ 932/** Success! */ 933#define __DRI_CTX_ERROR_SUCCESS 0 934 935/** Memory allocation failure */ 936#define __DRI_CTX_ERROR_NO_MEMORY 1 937 938/** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */ 939#define __DRI_CTX_ERROR_BAD_API 2 940 941/** Client requested an API version that the driver can't do. */ 942#define __DRI_CTX_ERROR_BAD_VERSION 3 943 944/** Client requested a flag or combination of flags the driver can't do. */ 945#define __DRI_CTX_ERROR_BAD_FLAG 4 946 947/** Client requested an attribute the driver doesn't understand. */ 948#define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5 949 950/** Client requested a flag the driver doesn't understand. */ 951#define __DRI_CTX_ERROR_UNKNOWN_FLAG 6 952/*@}*/ 953 954struct __DRIdri2ExtensionRec { 955 __DRIextension base; 956 957 __DRIscreen *(*createNewScreen)(int screen, int fd, 958 const __DRIextension **extensions, 959 const __DRIconfig ***driver_configs, 960 void *loaderPrivate); 961 962 __DRIcreateNewDrawableFunc createNewDrawable; 963 __DRIcontext *(*createNewContext)(__DRIscreen *screen, 964 const __DRIconfig *config, 965 __DRIcontext *shared, 966 void *loaderPrivate); 967 968 /* Since version 2 */ 969 __DRIgetAPIMaskFunc getAPIMask; 970 971 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen, 972 int api, 973 const __DRIconfig *config, 974 __DRIcontext *shared, 975 void *data); 976 977 __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen, 978 unsigned int attachment, 979 unsigned int format, 980 int width, 981 int height); 982 void (*releaseBuffer)(__DRIscreen *screen, 983 __DRIbuffer *buffer); 984 985 /** 986 * Create a context for a particular API with a set of attributes 987 * 988 * \since version 3 989 * 990 * \sa __DRIswrastExtensionRec::createContextAttribs 991 */ 992 __DRIcreateContextAttribsFunc createContextAttribs; 993 994 /** 995 * createNewScreen with the driver's extension list passed in. 996 * 997 * \since version 4 998 */ 999 __DRIcreateNewScreen2Func createNewScreen2; 1000}; 1001 1002 1003/** 1004 * This extension provides functionality to enable various EGLImage 1005 * extensions. 1006 */ 1007#define __DRI_IMAGE "DRI_IMAGE" 1008#define __DRI_IMAGE_VERSION 10 1009 1010/** 1011 * These formats correspond to the similarly named MESA_FORMAT_* 1012 * tokens, except in the native endian of the CPU. For example, on 1013 * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to 1014 * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian. 1015 * 1016 * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable 1017 * by the driver (YUV planar formats) but serve as a base image for 1018 * creating sub-images for the different planes within the image. 1019 * 1020 * R8, GR88 and NONE should not be used with createImageFormName or 1021 * createImage, and are returned by query from sub images created with 1022 * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88). 1023 */ 1024#define __DRI_IMAGE_FORMAT_RGB565 0x1001 1025#define __DRI_IMAGE_FORMAT_XRGB8888 0x1002 1026#define __DRI_IMAGE_FORMAT_ARGB8888 0x1003 1027#define __DRI_IMAGE_FORMAT_ABGR8888 0x1004 1028#define __DRI_IMAGE_FORMAT_XBGR8888 0x1005 1029#define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */ 1030#define __DRI_IMAGE_FORMAT_GR88 0x1007 1031#define __DRI_IMAGE_FORMAT_NONE 0x1008 1032#define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009 1033#define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a 1034#define __DRI_IMAGE_FORMAT_SARGB8 0x100b 1035 1036#define __DRI_IMAGE_USE_SHARE 0x0001 1037#define __DRI_IMAGE_USE_SCANOUT 0x0002 1038#define __DRI_IMAGE_USE_CURSOR 0x0004 /* Depricated */ 1039#define __DRI_IMAGE_USE_LINEAR 0x0008 1040 1041 1042/** 1043 * Four CC formats that matches with WL_DRM_FORMAT_* from wayland_drm.h 1044 * and GBM_FORMAT_* from gbm.h, used with createImageFromNames. 1045 * 1046 * \since 5 1047 */ 1048 1049#define __DRI_IMAGE_FOURCC_RGB565 0x36314752 1050#define __DRI_IMAGE_FOURCC_ARGB8888 0x34325241 1051#define __DRI_IMAGE_FOURCC_XRGB8888 0x34325258 1052#define __DRI_IMAGE_FOURCC_ABGR8888 0x34324241 1053#define __DRI_IMAGE_FOURCC_XBGR8888 0x34324258 1054#define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258 1055#define __DRI_IMAGE_FOURCC_YUV410 0x39565559 1056#define __DRI_IMAGE_FOURCC_YUV411 0x31315559 1057#define __DRI_IMAGE_FOURCC_YUV420 0x32315559 1058#define __DRI_IMAGE_FOURCC_YUV422 0x36315559 1059#define __DRI_IMAGE_FOURCC_YUV444 0x34325559 1060#define __DRI_IMAGE_FOURCC_NV12 0x3231564e 1061#define __DRI_IMAGE_FOURCC_NV16 0x3631564e 1062#define __DRI_IMAGE_FOURCC_YUYV 0x56595559 1063 1064 1065/** 1066 * Queryable on images created by createImageFromNames. 1067 * 1068 * RGB and RGBA are may be usable directly as images but its still 1069 * recommended to call fromPlanar with plane == 0. 1070 * 1071 * Y_U_V, Y_UV and Y_XUXV all requires call to fromPlanar to create 1072 * usable sub-images, sampling from images return raw YUV data and 1073 * color conversion needs to be done in the shader. 1074 * 1075 * \since 5 1076 */ 1077 1078#define __DRI_IMAGE_COMPONENTS_RGB 0x3001 1079#define __DRI_IMAGE_COMPONENTS_RGBA 0x3002 1080#define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003 1081#define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004 1082#define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005 1083 1084 1085/** 1086 * queryImage attributes 1087 */ 1088 1089#define __DRI_IMAGE_ATTRIB_STRIDE 0x2000 1090#define __DRI_IMAGE_ATTRIB_HANDLE 0x2001 1091#define __DRI_IMAGE_ATTRIB_NAME 0x2002 1092#define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */ 1093#define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */ 1094#define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005 1095#define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */ 1096#define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions 1097 * 7+. Each query will return a 1098 * new fd. */ 1099 1100enum __DRIYUVColorSpace { 1101 __DRI_YUV_COLOR_SPACE_UNDEFINED = 0, 1102 __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F, 1103 __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280, 1104 __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281 1105}; 1106 1107enum __DRISampleRange { 1108 __DRI_YUV_RANGE_UNDEFINED = 0, 1109 __DRI_YUV_FULL_RANGE = 0x3282, 1110 __DRI_YUV_NARROW_RANGE = 0x3283 1111}; 1112 1113enum __DRIChromaSiting { 1114 __DRI_YUV_CHROMA_SITING_UNDEFINED = 0, 1115 __DRI_YUV_CHROMA_SITING_0 = 0x3284, 1116 __DRI_YUV_CHROMA_SITING_0_5 = 0x3285 1117}; 1118 1119/** 1120 * \name Reasons that __DRIimageExtensionRec::createImageFromTexture might fail 1121 */ 1122/*@{*/ 1123/** Success! */ 1124#define __DRI_IMAGE_ERROR_SUCCESS 0 1125 1126/** Memory allocation failure */ 1127#define __DRI_IMAGE_ERROR_BAD_ALLOC 1 1128 1129/** Client requested an invalid attribute for a texture object */ 1130#define __DRI_IMAGE_ERROR_BAD_MATCH 2 1131 1132/** Client requested an invalid texture object */ 1133#define __DRI_IMAGE_ERROR_BAD_PARAMETER 3 1134/*@}*/ 1135 1136/** 1137 * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities 1138 */ 1139/*@{*/ 1140#define __DRI_IMAGE_CAP_GLOBAL_NAMES 1 1141/*@}*/ 1142 1143/** 1144 * blitImage flags 1145 */ 1146 1147#define __BLIT_FLAG_FLUSH 0x0001 1148#define __BLIT_FLAG_FINISH 0x0002 1149 1150typedef struct __DRIimageRec __DRIimage; 1151typedef struct __DRIimageExtensionRec __DRIimageExtension; 1152struct __DRIimageExtensionRec { 1153 __DRIextension base; 1154 1155 __DRIimage *(*createImageFromName)(__DRIscreen *screen, 1156 int width, int height, int format, 1157 int name, int pitch, 1158 void *loaderPrivate); 1159 1160 __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context, 1161 int renderbuffer, 1162 void *loaderPrivate); 1163 1164 void (*destroyImage)(__DRIimage *image); 1165 1166 __DRIimage *(*createImage)(__DRIscreen *screen, 1167 int width, int height, int format, 1168 unsigned int use, 1169 void *loaderPrivate); 1170 1171 GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value); 1172 1173 /** 1174 * The new __DRIimage will share the content with the old one, see dup(2). 1175 */ 1176 __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate); 1177 1178 /** 1179 * Validate that a __DRIimage can be used a certain way. 1180 * 1181 * \since 2 1182 */ 1183 GLboolean (*validateUsage)(__DRIimage *image, unsigned int use); 1184 1185 /** 1186 * Unlike createImageFromName __DRI_IMAGE_FORMAT is not but instead 1187 * __DRI_IMAGE_FOURCC and strides are in bytes not pixels. Stride is 1188 * also per block and not per pixel (for non-RGB, see gallium blocks). 1189 * 1190 * \since 5 1191 */ 1192 __DRIimage *(*createImageFromNames)(__DRIscreen *screen, 1193 int width, int height, int fourcc, 1194 int *names, int num_names, 1195 int *strides, int *offsets, 1196 void *loaderPrivate); 1197 1198 /** 1199 * Create an image out of a sub-region of a parent image. This 1200 * entry point lets us create individual __DRIimages for different 1201 * planes in a planar buffer (typically yuv), for example. While a 1202 * sub-image shares the underlying buffer object with the parent 1203 * image and other sibling sub-images, the life times of parent and 1204 * sub-images are not dependent. Destroying the parent or a 1205 * sub-image doesn't affect other images. The underlying buffer 1206 * object is free when no __DRIimage remains that references it. 1207 * 1208 * Sub-images may overlap, but rendering to overlapping sub-images 1209 * is undefined. 1210 * 1211 * \since 5 1212 */ 1213 __DRIimage *(*fromPlanar)(__DRIimage *image, int plane, 1214 void *loaderPrivate); 1215 1216 /** 1217 * Create image from texture. 1218 * 1219 * \since 6 1220 */ 1221 __DRIimage *(*createImageFromTexture)(__DRIcontext *context, 1222 int target, 1223 unsigned texture, 1224 int depth, 1225 int level, 1226 unsigned *error, 1227 void *loaderPrivate); 1228 /** 1229 * Like createImageFromNames, but takes a prime fd instead. 1230 * 1231 * \since 7 1232 */ 1233 __DRIimage *(*createImageFromFds)(__DRIscreen *screen, 1234 int width, int height, int fourcc, 1235 int *fds, int num_fds, 1236 int *strides, int *offsets, 1237 void *loaderPrivate); 1238 1239 /** 1240 * Like createImageFromFds, but takes additional attributes. 1241 * 1242 * For EGL_EXT_image_dma_buf_import. 1243 * 1244 * \since 8 1245 */ 1246 __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen, 1247 int width, int height, int fourcc, 1248 int *fds, int num_fds, 1249 int *strides, int *offsets, 1250 enum __DRIYUVColorSpace color_space, 1251 enum __DRISampleRange sample_range, 1252 enum __DRIChromaSiting horiz_siting, 1253 enum __DRIChromaSiting vert_siting, 1254 unsigned *error, 1255 void *loaderPrivate); 1256 1257 /** 1258 * Blit a part of a __DRIimage to another and flushes 1259 * 1260 * flush_flag: 1261 * 0: no flush 1262 * __BLIT_FLAG_FLUSH: flush after the blit operation 1263 * __BLIT_FLAG_FINISH: flush and wait the blit finished 1264 * 1265 * \since 9 1266 */ 1267 void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src, 1268 int dstx0, int dsty0, int dstwidth, int dstheight, 1269 int srcx0, int srcy0, int srcwidth, int srcheight, 1270 int flush_flag); 1271 1272 /** 1273 * Query for general capabilities of the driver that concern 1274 * buffer sharing and image importing. 1275 * 1276 * \since 10 1277 */ 1278 int (*getCapabilities)(__DRIscreen *screen); 1279}; 1280 1281 1282/** 1283 * This extension must be implemented by the loader and passed to the 1284 * driver at screen creation time. The EGLImage entry points in the 1285 * various client APIs take opaque EGLImage handles and use this 1286 * extension to map them to a __DRIimage. At version 1, this 1287 * extensions allows mapping EGLImage pointers to __DRIimage pointers, 1288 * but future versions could support other EGLImage-like, opaque types 1289 * with new lookup functions. 1290 */ 1291#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP" 1292#define __DRI_IMAGE_LOOKUP_VERSION 1 1293 1294typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension; 1295struct __DRIimageLookupExtensionRec { 1296 __DRIextension base; 1297 1298 __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image, 1299 void *loaderPrivate); 1300}; 1301 1302/** 1303 * This extension allows for common DRI2 options 1304 */ 1305#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY" 1306#define __DRI2_CONFIG_QUERY_VERSION 1 1307 1308typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension; 1309struct __DRI2configQueryExtensionRec { 1310 __DRIextension base; 1311 1312 int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val); 1313 int (*configQueryi)(__DRIscreen *screen, const char *var, int *val); 1314 int (*configQueryf)(__DRIscreen *screen, const char *var, float *val); 1315}; 1316 1317/** 1318 * Robust context driver extension. 1319 * 1320 * Existence of this extension means the driver can accept the 1321 * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the 1322 * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in 1323 * \c __DRIdri2ExtensionRec::createContextAttribs. 1324 */ 1325#define __DRI2_ROBUSTNESS "DRI_Robustness" 1326#define __DRI2_ROBUSTNESS_VERSION 1 1327 1328typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension; 1329struct __DRIrobustnessExtensionRec { 1330 __DRIextension base; 1331}; 1332 1333/** 1334 * DRI config options extension. 1335 * 1336 * This extension provides the XML string containing driver options for use by 1337 * the loader in supporting the driconf application. 1338 */ 1339#define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions" 1340#define __DRI_CONFIG_OPTIONS_VERSION 1 1341 1342typedef struct __DRIconfigOptionsExtensionRec { 1343 __DRIextension base; 1344 const char *xml; 1345} __DRIconfigOptionsExtension; 1346 1347/** 1348 * This extension provides a driver vtable to a set of common driver helper 1349 * functions (driCoreExtension, driDRI2Extension) within the driver 1350 * implementation, as opposed to having to pass them through a global 1351 * variable. 1352 * 1353 * It is not intended to be public API to the actual loader, and the vtable 1354 * layout may change at any time. 1355 */ 1356#define __DRI_DRIVER_VTABLE "DRI_DriverVtable" 1357#define __DRI_DRIVER_VTABLE_VERSION 1 1358 1359typedef struct __DRIDriverVtableExtensionRec { 1360 __DRIextension base; 1361 const struct __DriverAPIRec *vtable; 1362} __DRIDriverVtableExtension; 1363 1364/** 1365 * Query renderer driver extension 1366 * 1367 * This allows the window system layer (either EGL or GLX) to query aspects of 1368 * hardware and driver support without creating a context. 1369 */ 1370#define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY" 1371#define __DRI2_RENDERER_QUERY_VERSION 1 1372 1373#define __DRI2_RENDERER_VENDOR_ID 0x0000 1374#define __DRI2_RENDERER_DEVICE_ID 0x0001 1375#define __DRI2_RENDERER_VERSION 0x0002 1376#define __DRI2_RENDERER_ACCELERATED 0x0003 1377#define __DRI2_RENDERER_VIDEO_MEMORY 0x0004 1378#define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005 1379#define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006 1380#define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007 1381#define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008 1382#define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009 1383#define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a 1384 1385typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension; 1386struct __DRI2rendererQueryExtensionRec { 1387 __DRIextension base; 1388 1389 int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val); 1390 int (*queryString)(__DRIscreen *screen, int attribute, const char **val); 1391}; 1392 1393/** 1394 * Image Loader extension. Drivers use this to allocate color buffers 1395 */ 1396 1397enum __DRIimageBufferMask { 1398 __DRI_IMAGE_BUFFER_BACK = (1 << 0), 1399 __DRI_IMAGE_BUFFER_FRONT = (1 << 1) 1400}; 1401 1402struct __DRIimageList { 1403 uint32_t image_mask; 1404 __DRIimage *back; 1405 __DRIimage *front; 1406}; 1407 1408#define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER" 1409#define __DRI_IMAGE_LOADER_VERSION 1 1410 1411struct __DRIimageLoaderExtensionRec { 1412 __DRIextension base; 1413 1414 /** 1415 * Allocate color buffers. 1416 * 1417 * \param driDrawable 1418 * \param width Width of allocated buffers 1419 * \param height Height of allocated buffers 1420 * \param format one of __DRI_IMAGE_FORMAT_* 1421 * \param stamp Address of variable to be updated when 1422 * getBuffers must be called again 1423 * \param loaderPrivate The loaderPrivate for driDrawable 1424 * \param buffer_mask Set of buffers to allocate 1425 * \param buffers Returned buffers 1426 */ 1427 int (*getBuffers)(__DRIdrawable *driDrawable, 1428 unsigned int format, 1429 uint32_t *stamp, 1430 void *loaderPrivate, 1431 uint32_t buffer_mask, 1432 struct __DRIimageList *buffers); 1433 1434 /** 1435 * Flush pending front-buffer rendering 1436 * 1437 * Any rendering that has been performed to the 1438 * fake front will be flushed to the front 1439 * 1440 * \param driDrawable Drawable whose front-buffer is to be flushed 1441 * \param loaderPrivate Loader's private data that was previously passed 1442 * into __DRIdri2ExtensionRec::createNewDrawable 1443 */ 1444 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate); 1445}; 1446 1447/** 1448 * DRI extension. 1449 */ 1450 1451#define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER" 1452#define __DRI_IMAGE_DRIVER_VERSION 1 1453 1454struct __DRIimageDriverExtensionRec { 1455 __DRIextension base; 1456 1457 /* Common DRI functions, shared with DRI2 */ 1458 __DRIcreateNewScreen2Func createNewScreen2; 1459 __DRIcreateNewDrawableFunc createNewDrawable; 1460 __DRIcreateContextAttribsFunc createContextAttribs; 1461 __DRIgetAPIMaskFunc getAPIMask; 1462}; 1463 1464#endif 1465