Path: blob/21.2-virgl/include/GL/internal/dri_interface.h
7100 views
/*1* Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.2* Copyright 2007-2008 Red Hat, Inc.3* (C) Copyright IBM Corporation 20044* All Rights Reserved.5*6* Permission is hereby granted, free of charge, to any person obtaining a7* copy of this software and associated documentation files (the "Software"),8* to deal in the Software without restriction, including without limitation9* on the rights to use, copy, modify, merge, publish, distribute, sub10* license, and/or sell copies of the Software, and to permit persons to whom11* the Software is furnished to do so, subject to the following conditions:12*13* The above copyright notice and this permission notice (including the next14* paragraph) shall be included in all copies or substantial portions of the15* Software.16*17* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR18* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,19* FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL20* THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,21* DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR22* OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE23* USE OR OTHER DEALINGS IN THE SOFTWARE.24*/2526/**27* \file dri_interface.h28*29* This file contains all the types and functions that define the interface30* between a DRI driver and driver loader. Currently, the most common driver31* loader is the XFree86 libGL.so. However, other loaders do exist, and in32* the future the server-side libglx.a will also be a loader.33*34* \author Kevin E. Martin <[email protected]>35* \author Ian Romanick <[email protected]>36* \author Kristian Høgsberg <[email protected]>37*/3839#ifndef DRI_INTERFACE_H40#define DRI_INTERFACE_H4142#ifdef HAVE_LIBDRM43#include <drm.h>44#else45typedef unsigned int drm_context_t;46typedef unsigned int drm_drawable_t;47typedef struct drm_clip_rect drm_clip_rect_t;48#endif4950#include <GL/gl.h>5152#include <stdint.h>5354/**55* \name DRI interface structures56*57* The following structures define the interface between the GLX client58* side library and the DRI (direct rendering infrastructure).59*/60/*@{*/61typedef struct __DRIdisplayRec __DRIdisplay;62typedef struct __DRIscreenRec __DRIscreen;63typedef struct __DRIcontextRec __DRIcontext;64typedef struct __DRIdrawableRec __DRIdrawable;65typedef struct __DRIconfigRec __DRIconfig;66typedef struct __DRIframebufferRec __DRIframebuffer;67typedef struct __DRIversionRec __DRIversion;6869typedef struct __DRIcoreExtensionRec __DRIcoreExtension;70typedef struct __DRIextensionRec __DRIextension;71typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;72typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;73typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;74typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;75typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;76typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;77typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;78typedef struct __DRIswrastExtensionRec __DRIswrastExtension;79typedef struct __DRIbufferRec __DRIbuffer;80typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;81typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;82typedef struct __DRI2flushExtensionRec __DRI2flushExtension;83typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension;84typedef struct __DRI2fenceExtensionRec __DRI2fenceExtension;85typedef struct __DRI2interopExtensionRec __DRI2interopExtension;86typedef struct __DRI2blobExtensionRec __DRI2blobExtension;87typedef struct __DRI2bufferDamageExtensionRec __DRI2bufferDamageExtension;8889typedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension;90typedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension;9192/*@}*/939495/**96* Extension struct. Drivers 'inherit' from this struct by embedding97* it as the first element in the extension struct.98*99* We never break API in for a DRI extension. If we need to change100* the way things work in a non-backwards compatible manner, we101* introduce a new extension. During a transition period, we can102* leave both the old and the new extension in the driver, which103* allows us to move to the new interface without having to update the104* loader(s) in lock step.105*106* However, we can add entry points to an extension over time as long107* as we don't break the old ones. As we add entry points to an108* extension, we increase the version number. The corresponding109* #define can be used to guard code that accesses the new entry110* points at compile time and the version field in the extension111* struct can be used at run-time to determine how to use the112* extension.113*/114struct __DRIextensionRec {115const char *name;116int version;117};118119/**120* The first set of extension are the screen extensions, returned by121* __DRIcore::getExtensions(). This entry point will return a list of122* extensions and the loader can use the ones it knows about by123* casting them to more specific extensions and advertising any GLX124* extensions the DRI extensions enables.125*/126127/**128* Used by drivers to indicate support for setting the read drawable.129*/130#define __DRI_READ_DRAWABLE "DRI_ReadDrawable"131#define __DRI_READ_DRAWABLE_VERSION 1132133/**134* Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.135*/136#define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"137#define __DRI_COPY_SUB_BUFFER_VERSION 1138struct __DRIcopySubBufferExtensionRec {139__DRIextension base;140void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);141};142143/**144* Used by drivers that implement the GLX_SGI_swap_control or145* GLX_MESA_swap_control extension.146*/147#define __DRI_SWAP_CONTROL "DRI_SwapControl"148#define __DRI_SWAP_CONTROL_VERSION 1149struct __DRIswapControlExtensionRec {150__DRIextension base;151void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);152unsigned int (*getSwapInterval)(__DRIdrawable *drawable);153};154155/**156* Used by drivers that implement the GLX_MESA_swap_frame_usage extension.157*/158#define __DRI_FRAME_TRACKING "DRI_FrameTracking"159#define __DRI_FRAME_TRACKING_VERSION 1160struct __DRIframeTrackingExtensionRec {161__DRIextension base;162163/**164* Enable or disable frame usage tracking.165*166* \since Internal API version 20030317.167*/168int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable);169170/**171* Retrieve frame usage information.172*173* \since Internal API version 20030317.174*/175int (*queryFrameTracking)(__DRIdrawable *drawable,176int64_t * sbc, int64_t * missedFrames,177float * lastMissedUsage, float * usage);178};179180181/**182* Used by drivers that implement the GLX_SGI_video_sync extension.183*/184#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"185#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1186struct __DRImediaStreamCounterExtensionRec {187__DRIextension base;188189/**190* Wait for the MSC to equal target_msc, or, if that has already passed,191* the next time (MSC % divisor) is equal to remainder. If divisor is192* zero, the function will return as soon as MSC is greater than or equal193* to target_msc.194*/195int (*waitForMSC)(__DRIdrawable *drawable,196int64_t target_msc, int64_t divisor, int64_t remainder,197int64_t * msc, int64_t * sbc);198199/**200* Get the number of vertical refreshes since some point in time before201* this function was first called (i.e., system start up).202*/203int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,204int64_t *msc);205};206207208#define __DRI_TEX_OFFSET "DRI_TexOffset"209#define __DRI_TEX_OFFSET_VERSION 1210struct __DRItexOffsetExtensionRec {211__DRIextension base;212213/**214* Method to override base texture image with a driver specific 'offset'.215* The depth passed in allows e.g. to ignore the alpha channel of texture216* images where the non-alpha components don't occupy a whole texel.217*218* For GLX_EXT_texture_from_pixmap with AIGLX.219*/220void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,221unsigned long long offset, GLint depth, GLuint pitch);222};223224225/* Valid values for format in the setTexBuffer2 function below. These226* values match the GLX tokens for compatibility reasons, but we227* define them here since the DRI interface can't depend on GLX. */228#define __DRI_TEXTURE_FORMAT_NONE 0x20D8229#define __DRI_TEXTURE_FORMAT_RGB 0x20D9230#define __DRI_TEXTURE_FORMAT_RGBA 0x20DA231232#define __DRI_TEX_BUFFER "DRI_TexBuffer"233#define __DRI_TEX_BUFFER_VERSION 3234struct __DRItexBufferExtensionRec {235__DRIextension base;236237/**238* Method to override base texture image with the contents of a239* __DRIdrawable.240*241* For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of242* setTexBuffer2 in version 2 of this interface243*/244void (*setTexBuffer)(__DRIcontext *pDRICtx,245GLint target,246__DRIdrawable *pDraw);247248/**249* Method to override base texture image with the contents of a250* __DRIdrawable, including the required texture format attribute.251*252* For GLX_EXT_texture_from_pixmap with AIGLX.253*254* \since 2255*/256void (*setTexBuffer2)(__DRIcontext *pDRICtx,257GLint target,258GLint format,259__DRIdrawable *pDraw);260/**261* Method to release texture buffer in case some special platform262* need this.263*264* For GLX_EXT_texture_from_pixmap with AIGLX.265*266* \since 3267*/268void (*releaseTexBuffer)(__DRIcontext *pDRICtx,269GLint target,270__DRIdrawable *pDraw);271};272273/**274* Used by drivers that implement DRI2275*/276#define __DRI2_FLUSH "DRI2_Flush"277#define __DRI2_FLUSH_VERSION 4278279#define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */280#define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */281#define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2)282283enum __DRI2throttleReason {284__DRI2_THROTTLE_SWAPBUFFER,285__DRI2_THROTTLE_COPYSUBBUFFER,286__DRI2_THROTTLE_FLUSHFRONT287};288289struct __DRI2flushExtensionRec {290__DRIextension base;291void (*flush)(__DRIdrawable *drawable);292293/**294* Ask the driver to call getBuffers/getBuffersWithFormat before295* it starts rendering again.296*297* \param drawable the drawable to invalidate298*299* \since 3300*/301void (*invalidate)(__DRIdrawable *drawable);302303/**304* This function reduces the number of flushes in the driver by combining305* several operations into one call.306*307* It can:308* - throttle309* - flush a drawable310* - flush a context311*312* \param context the context313* \param drawable the drawable to flush314* \param flags a combination of _DRI2_FLUSH_xxx flags315* \param throttle_reason the reason for throttling, 0 = no throttling316*317* \since 4318*/319void (*flush_with_flags)(__DRIcontext *ctx,320__DRIdrawable *drawable,321unsigned flags,322enum __DRI2throttleReason throttle_reason);323};324325326/**327* Extension that the driver uses to request328* throttle callbacks.329*/330331#define __DRI2_THROTTLE "DRI2_Throttle"332#define __DRI2_THROTTLE_VERSION 1333334struct __DRI2throttleExtensionRec {335__DRIextension base;336void (*throttle)(__DRIcontext *ctx,337__DRIdrawable *drawable,338enum __DRI2throttleReason reason);339};340341/**342* Extension for EGL_ANDROID_blob_cache343*/344345#define __DRI2_BLOB "DRI2_Blob"346#define __DRI2_BLOB_VERSION 1347348typedef void349(*__DRIblobCacheSet) (const void *key, signed long keySize,350const void *value, signed long valueSize);351352typedef signed long353(*__DRIblobCacheGet) (const void *key, signed long keySize,354void *value, signed long valueSize);355356struct __DRI2blobExtensionRec {357__DRIextension base;358359/**360* Set cache functions for setting and getting cache entries.361*/362void (*set_cache_funcs) (__DRIscreen *screen,363__DRIblobCacheSet set, __DRIblobCacheGet get);364};365366/**367* Extension for fences / synchronization objects.368*/369370#define __DRI2_FENCE "DRI2_Fence"371#define __DRI2_FENCE_VERSION 2372373#define __DRI2_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffull374375#define __DRI2_FENCE_FLAG_FLUSH_COMMANDS (1 << 0)376377/**378* \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities379*/380/*@{*/381#define __DRI_FENCE_CAP_NATIVE_FD 1382/*@}*/383384struct __DRI2fenceExtensionRec {385__DRIextension base;386387/**388* Create and insert a fence into the command stream of the context.389*/390void *(*create_fence)(__DRIcontext *ctx);391392/**393* Get a fence associated with the OpenCL event object.394* This can be NULL, meaning that OpenCL interoperability is not supported.395*/396void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event);397398/**399* Destroy a fence.400*/401void (*destroy_fence)(__DRIscreen *screen, void *fence);402403/**404* This function waits and doesn't return until the fence is signalled405* or the timeout expires. It returns true if the fence has been signaled.406*407* \param ctx the context where commands are flushed408* \param fence the fence409* \param flags a combination of __DRI2_FENCE_FLAG_xxx flags410* \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE411*/412GLboolean (*client_wait_sync)(__DRIcontext *ctx, void *fence,413unsigned flags, uint64_t timeout);414415/**416* This function enqueues a wait command into the command stream of417* the context and then returns. When the execution reaches the wait418* command, no further execution will be done in the context until419* the fence is signaled. This is a no-op if the device doesn't support420* parallel execution of contexts.421*422* \param ctx the context where the waiting is done423* \param fence the fence424* \param flags a combination of __DRI2_FENCE_FLAG_xxx flags that make425* sense with this function (right now there are none)426*/427void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags);428429/**430* Query for general capabilities of the driver that concern fences.431* Returns a bitmask of __DRI_FENCE_CAP_x432*433* \since 2434*/435unsigned (*get_capabilities)(__DRIscreen *screen);436437/**438* Create an fd (file descriptor) associated fence. If the fence fd439* is -1, this behaves similarly to create_fence() except that when440* rendering is flushed the driver creates a fence fd. Otherwise,441* the driver wraps an existing fence fd.442*443* This is used to implement the EGL_ANDROID_native_fence_sync extension.444*445* \since 2446*447* \param ctx the context associated with the fence448* \param fd the fence fd or -1449*/450void *(*create_fence_fd)(__DRIcontext *ctx, int fd);451452/**453* For fences created with create_fence_fd(), after rendering is flushed,454* this retrieves the native fence fd. Caller takes ownership of the455* fd and will close() it when it is no longer needed.456*457* \since 2458*459* \param screen the screen associated with the fence460* \param fence the fence461*/462int (*get_fence_fd)(__DRIscreen *screen, void *fence);463};464465466/**467* Extension for API interop.468* See GL/mesa_glinterop.h.469*/470471#define __DRI2_INTEROP "DRI2_Interop"472#define __DRI2_INTEROP_VERSION 1473474struct mesa_glinterop_device_info;475struct mesa_glinterop_export_in;476struct mesa_glinterop_export_out;477478struct __DRI2interopExtensionRec {479__DRIextension base;480481/** Same as MesaGLInterop*QueryDeviceInfo. */482int (*query_device_info)(__DRIcontext *ctx,483struct mesa_glinterop_device_info *out);484485/** Same as MesaGLInterop*ExportObject. */486int (*export_object)(__DRIcontext *ctx,487struct mesa_glinterop_export_in *in,488struct mesa_glinterop_export_out *out);489};490491492/**493* Extension for limiting window system back buffer rendering to user-defined494* scissor region.495*/496497#define __DRI2_BUFFER_DAMAGE "DRI2_BufferDamage"498#define __DRI2_BUFFER_DAMAGE_VERSION 1499500struct __DRI2bufferDamageExtensionRec {501__DRIextension base;502503/**504* Provides an array of rectangles representing an overriding scissor region505* for rendering operations performed to the specified drawable. These506* rectangles do not replace client API scissor regions or draw507* co-ordinates, but instead inform the driver of the overall bounds of all508* operations which will be issued before the next flush.509*510* Any rendering operations writing pixels outside this region to the511* drawable will have an undefined effect on the entire drawable.512*513* This entrypoint may only be called after the drawable has either been514* newly created or flushed, and before any rendering operations which write515* pixels to the drawable. Calling this entrypoint at any other time will516* have an undefined effect on the entire drawable.517*518* Calling this entrypoint with @nrects 0 and @rects NULL will reset the519* region to the buffer's full size. This entrypoint may be called once to520* reset the region, followed by a second call with a populated region,521* before a rendering call is made.522*523* Used to implement EGL_KHR_partial_update.524*525* \param drawable affected drawable526* \param nrects number of rectangles provided527* \param rects the array of rectangles, lower-left origin528*/529void (*set_damage_region)(__DRIdrawable *drawable, unsigned int nrects,530int *rects);531};532533/*@}*/534535/**536* The following extensions describe loader features that the DRI537* driver can make use of. Some of these are mandatory, such as the538* getDrawableInfo extension for DRI and the DRI Loader extensions for539* DRI2, while others are optional, and if present allow the driver to540* expose certain features. The loader pass in a NULL terminated541* array of these extensions to the driver in the createNewScreen542* constructor.543*/544545typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;546typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;547typedef struct __DRIdamageExtensionRec __DRIdamageExtension;548typedef struct __DRIloaderExtensionRec __DRIloaderExtension;549typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;550551552/**553* Callback to getDrawableInfo protocol554*/555#define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"556#define __DRI_GET_DRAWABLE_INFO_VERSION 1557struct __DRIgetDrawableInfoExtensionRec {558__DRIextension base;559560/**561* This function is used to get information about the position, size, and562* clip rects of a drawable.563*/564GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,565unsigned int * index, unsigned int * stamp,566int * x, int * y, int * width, int * height,567int * numClipRects, drm_clip_rect_t ** pClipRects,568int * backX, int * backY,569int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,570void *loaderPrivate);571};572573/**574* Callback to get system time for media stream counter extensions.575*/576#define __DRI_SYSTEM_TIME "DRI_SystemTime"577#define __DRI_SYSTEM_TIME_VERSION 1578struct __DRIsystemTimeExtensionRec {579__DRIextension base;580581/**582* Get the 64-bit unadjusted system time (UST).583*/584int (*getUST)(int64_t * ust);585586/**587* Get the media stream counter (MSC) rate.588*589* Matching the definition in GLX_OML_sync_control, this function returns590* the rate of the "media stream counter". In practical terms, this is591* the frame refresh rate of the display.592*/593GLboolean (*getMSCRate)(__DRIdrawable *draw,594int32_t * numerator, int32_t * denominator,595void *loaderPrivate);596};597598/**599* Damage reporting600*/601#define __DRI_DAMAGE "DRI_Damage"602#define __DRI_DAMAGE_VERSION 1603struct __DRIdamageExtensionRec {604__DRIextension base;605606/**607* Reports areas of the given drawable which have been modified by the608* driver.609*610* \param drawable which the drawing was done to.611* \param rects rectangles affected, with the drawable origin as the612* origin.613* \param x X offset of the drawable within the screen (used in the614* front_buffer case)615* \param y Y offset of the drawable within the screen.616* \param front_buffer boolean flag for whether the drawing to the617* drawable was actually done directly to the front buffer (instead618* of backing storage, for example)619* \param loaderPrivate the data passed in at createNewDrawable time620*/621void (*reportDamage)(__DRIdrawable *draw,622int x, int y,623drm_clip_rect_t *rects, int num_rects,624GLboolean front_buffer,625void *loaderPrivate);626};627628#define __DRI_SWRAST_IMAGE_OP_DRAW 1629#define __DRI_SWRAST_IMAGE_OP_CLEAR 2630#define __DRI_SWRAST_IMAGE_OP_SWAP 3631632/**633* SWRast Loader extension.634*/635#define __DRI_SWRAST_LOADER "DRI_SWRastLoader"636#define __DRI_SWRAST_LOADER_VERSION 6637struct __DRIswrastLoaderExtensionRec {638__DRIextension base;639640/*641* Drawable position and size642*/643void (*getDrawableInfo)(__DRIdrawable *drawable,644int *x, int *y, int *width, int *height,645void *loaderPrivate);646647/**648* Put image to drawable649*/650void (*putImage)(__DRIdrawable *drawable, int op,651int x, int y, int width, int height,652char *data, void *loaderPrivate);653654/**655* Get image from readable656*/657void (*getImage)(__DRIdrawable *readable,658int x, int y, int width, int height,659char *data, void *loaderPrivate);660661/**662* Put image to drawable663*664* \since 2665*/666void (*putImage2)(__DRIdrawable *drawable, int op,667int x, int y, int width, int height, int stride,668char *data, void *loaderPrivate);669670/**671* Put image to drawable672*673* \since 3674*/675void (*getImage2)(__DRIdrawable *readable,676int x, int y, int width, int height, int stride,677char *data, void *loaderPrivate);678679/**680* Put shm image to drawable681*682* \since 4683*/684void (*putImageShm)(__DRIdrawable *drawable, int op,685int x, int y, int width, int height, int stride,686int shmid, char *shmaddr, unsigned offset,687void *loaderPrivate);688/**689* Get shm image from readable690*691* \since 4692*/693void (*getImageShm)(__DRIdrawable *readable,694int x, int y, int width, int height,695int shmid, void *loaderPrivate);696697/**698* Put shm image to drawable (v2)699*700* The original version fixes srcx/y to 0, and expected701* the offset to be adjusted. This version allows src x,y702* to not be included in the offset. This is needed to703* avoid certain overflow checks in the X server, that704* result in lost rendering.705*706* \since 5707*/708void (*putImageShm2)(__DRIdrawable *drawable, int op,709int x, int y,710int width, int height, int stride,711int shmid, char *shmaddr, unsigned offset,712void *loaderPrivate);713714/**715* get shm image to drawable (v2)716*717* There are some cases where GLX can't use SHM, but DRI718* still tries, we need to get a return type for when to719* fallback to the non-shm path.720*721* \since 6722*/723GLboolean (*getImageShm2)(__DRIdrawable *readable,724int x, int y, int width, int height,725int shmid, void *loaderPrivate);726};727728/**729* Invalidate loader extension. The presence of this extension730* indicates to the DRI driver that the loader will call invalidate in731* the __DRI2_FLUSH extension, whenever the needs to query for new732* buffers. This means that the DRI driver can drop the polling in733* glViewport().734*735* The extension doesn't provide any functionality, it's only use to736* indicate to the driver that it can use the new semantics. A DRI737* driver can use this to switch between the different semantics or738* just refuse to initialize if this extension isn't present.739*/740#define __DRI_USE_INVALIDATE "DRI_UseInvalidate"741#define __DRI_USE_INVALIDATE_VERSION 1742743typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;744struct __DRIuseInvalidateExtensionRec {745__DRIextension base;746};747748/**749* The remaining extensions describe driver extensions, immediately750* available interfaces provided by the driver. To start using the751* driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for752* the extension you need in the array.753*/754#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"755756/**757* This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be758* suffixed by "_drivername", allowing multiple drivers to be built into one759* library, and also giving the driver the chance to return a variable driver760* extensions struct depending on the driver name being loaded or any other761* system state.762*763* The function prototype is:764*765* const __DRIextension **__driDriverGetExtensions_drivername(void);766*/767#define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"768769/**770* Tokens for __DRIconfig attribs. A number of attributes defined by771* GLX or EGL standards are not in the table, as they must be provided772* by the loader. For example, FBConfig ID or visual ID, drawable type.773*/774775#define __DRI_ATTRIB_BUFFER_SIZE 1776#define __DRI_ATTRIB_LEVEL 2777#define __DRI_ATTRIB_RED_SIZE 3778#define __DRI_ATTRIB_GREEN_SIZE 4779#define __DRI_ATTRIB_BLUE_SIZE 5780#define __DRI_ATTRIB_LUMINANCE_SIZE 6781#define __DRI_ATTRIB_ALPHA_SIZE 7782#define __DRI_ATTRIB_ALPHA_MASK_SIZE 8783#define __DRI_ATTRIB_DEPTH_SIZE 9784#define __DRI_ATTRIB_STENCIL_SIZE 10785#define __DRI_ATTRIB_ACCUM_RED_SIZE 11786#define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12787#define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13788#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14789#define __DRI_ATTRIB_SAMPLE_BUFFERS 15790#define __DRI_ATTRIB_SAMPLES 16791#define __DRI_ATTRIB_RENDER_TYPE 17792#define __DRI_ATTRIB_CONFIG_CAVEAT 18793#define __DRI_ATTRIB_CONFORMANT 19794#define __DRI_ATTRIB_DOUBLE_BUFFER 20795#define __DRI_ATTRIB_STEREO 21796#define __DRI_ATTRIB_AUX_BUFFERS 22797#define __DRI_ATTRIB_TRANSPARENT_TYPE 23798#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24799#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25800#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26801#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27802#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28803#define __DRI_ATTRIB_FLOAT_MODE 29804#define __DRI_ATTRIB_RED_MASK 30805#define __DRI_ATTRIB_GREEN_MASK 31806#define __DRI_ATTRIB_BLUE_MASK 32807#define __DRI_ATTRIB_ALPHA_MASK 33808#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34809#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35810#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36811#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37812#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38813#define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39814#define __DRI_ATTRIB_SWAP_METHOD 40815#define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41816#define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42817#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43818#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44819#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45820#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46821#define __DRI_ATTRIB_YINVERTED 47822#define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48823#define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER 49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */824#define __DRI_ATTRIB_RED_SHIFT 50825#define __DRI_ATTRIB_GREEN_SHIFT 51826#define __DRI_ATTRIB_BLUE_SHIFT 52827#define __DRI_ATTRIB_ALPHA_SHIFT 53828#define __DRI_ATTRIB_MAX 54829830/* __DRI_ATTRIB_RENDER_TYPE */831#define __DRI_ATTRIB_RGBA_BIT 0x01832#define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02833#define __DRI_ATTRIB_LUMINANCE_BIT 0x04834#define __DRI_ATTRIB_FLOAT_BIT 0x08835#define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10836837/* __DRI_ATTRIB_CONFIG_CAVEAT */838#define __DRI_ATTRIB_SLOW_BIT 0x01839#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02840841/* __DRI_ATTRIB_TRANSPARENT_TYPE */842#define __DRI_ATTRIB_TRANSPARENT_RGB 0x00843#define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01844845/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */846#define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01847#define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02848#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04849850/* __DRI_ATTRIB_SWAP_METHOD */851/* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define852* the same tokens as GLX. This is because old and current X servers will853* transmit the driconf value grabbed from the AIGLX driver untranslated as854* the GLX fbconfig value. __DRI_ATTRIB_SWAP_NONE is only used by dri drivers855* to signal to the dri core that the driconfig is single-buffer.856*/857#define __DRI_ATTRIB_SWAP_NONE 0x0000858#define __DRI_ATTRIB_SWAP_EXCHANGE 0x8061859#define __DRI_ATTRIB_SWAP_COPY 0x8062860#define __DRI_ATTRIB_SWAP_UNDEFINED 0x8063861862/**863* This extension defines the core DRI functionality.864*865* Version >= 2 indicates that getConfigAttrib with __DRI_ATTRIB_SWAP_METHOD866* returns a reliable value.867*/868#define __DRI_CORE "DRI_Core"869#define __DRI_CORE_VERSION 2870871struct __DRIcoreExtensionRec {872__DRIextension base;873874__DRIscreen *(*createNewScreen)(int screen, int fd,875unsigned int sarea_handle,876const __DRIextension **extensions,877const __DRIconfig ***driverConfigs,878void *loaderPrivate);879880void (*destroyScreen)(__DRIscreen *screen);881882const __DRIextension **(*getExtensions)(__DRIscreen *screen);883884int (*getConfigAttrib)(const __DRIconfig *config,885unsigned int attrib,886unsigned int *value);887888int (*indexConfigAttrib)(const __DRIconfig *config, int index,889unsigned int *attrib, unsigned int *value);890891__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,892const __DRIconfig *config,893unsigned int drawable_id,894unsigned int head,895void *loaderPrivate);896897void (*destroyDrawable)(__DRIdrawable *drawable);898899void (*swapBuffers)(__DRIdrawable *drawable);900901__DRIcontext *(*createNewContext)(__DRIscreen *screen,902const __DRIconfig *config,903__DRIcontext *shared,904void *loaderPrivate);905906int (*copyContext)(__DRIcontext *dest,907__DRIcontext *src,908unsigned long mask);909910void (*destroyContext)(__DRIcontext *context);911912int (*bindContext)(__DRIcontext *ctx,913__DRIdrawable *pdraw,914__DRIdrawable *pread);915916int (*unbindContext)(__DRIcontext *ctx);917};918919/**920* Stored version of some component (i.e., server-side DRI module, kernel-side921* DRM, etc.).922*923* \todo924* There are several data structures that explicitly store a major version,925* minor version, and patch level. These structures should be modified to926* have a \c __DRIversionRec instead.927*/928struct __DRIversionRec {929int major; /**< Major version number. */930int minor; /**< Minor version number. */931int patch; /**< Patch-level. */932};933934/**935* Framebuffer information record. Used by libGL to communicate information936* about the framebuffer to the driver's \c __driCreateNewScreen function.937*938* In XFree86, most of this information is derrived from data returned by939* calling \c XF86DRIGetDeviceInfo.940*941* \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen942* __driUtilCreateNewScreen CallCreateNewScreen943*944* \bug This structure could be better named.945*/946struct __DRIframebufferRec {947unsigned char *base; /**< Framebuffer base address in the CPU's948* address space. This value is calculated by949* calling \c drmMap on the framebuffer handle950* returned by \c XF86DRIGetDeviceInfo (or a951* similar function).952*/953int size; /**< Framebuffer size, in bytes. */954int stride; /**< Number of bytes from one line to the next. */955int width; /**< Pixel width of the framebuffer. */956int height; /**< Pixel height of the framebuffer. */957int dev_priv_size; /**< Size of the driver's dev-priv structure. */958void *dev_priv; /**< Pointer to the driver's dev-priv structure. */959};960961962/**963* This extension provides alternative screen, drawable and context964* constructors for legacy DRI functionality. This is used in965* conjunction with the core extension.966*/967#define __DRI_LEGACY "DRI_Legacy"968#define __DRI_LEGACY_VERSION 1969970struct __DRIlegacyExtensionRec {971__DRIextension base;972973__DRIscreen *(*createNewScreen)(int screen,974const __DRIversion *ddx_version,975const __DRIversion *dri_version,976const __DRIversion *drm_version,977const __DRIframebuffer *frame_buffer,978void *pSAREA, int fd,979const __DRIextension **extensions,980const __DRIconfig ***driver_configs,981void *loaderPrivate);982983__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,984const __DRIconfig *config,985drm_drawable_t hwDrawable,986int renderType, const int *attrs,987void *loaderPrivate);988989__DRIcontext *(*createNewContext)(__DRIscreen *screen,990const __DRIconfig *config,991int render_type,992__DRIcontext *shared,993drm_context_t hwContext,994void *loaderPrivate);995};996997/**998* This extension provides alternative screen, drawable and context999* constructors for swrast DRI functionality. This is used in1000* conjunction with the core extension.1001*/1002#define __DRI_SWRAST "DRI_SWRast"1003#define __DRI_SWRAST_VERSION 410041005struct __DRIswrastExtensionRec {1006__DRIextension base;10071008__DRIscreen *(*createNewScreen)(int screen,1009const __DRIextension **extensions,1010const __DRIconfig ***driver_configs,1011void *loaderPrivate);10121013__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,1014const __DRIconfig *config,1015void *loaderPrivate);10161017/* Since version 2 */1018__DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,1019int api,1020const __DRIconfig *config,1021__DRIcontext *shared,1022void *data);10231024/**1025* Create a context for a particular API with a set of attributes1026*1027* \since version 31028*1029* \sa __DRIdri2ExtensionRec::createContextAttribs1030*/1031__DRIcontext *(*createContextAttribs)(__DRIscreen *screen,1032int api,1033const __DRIconfig *config,1034__DRIcontext *shared,1035unsigned num_attribs,1036const uint32_t *attribs,1037unsigned *error,1038void *loaderPrivate);10391040/**1041* createNewScreen() with the driver extensions passed in.1042*1043* \since version 41044*/1045__DRIscreen *(*createNewScreen2)(int screen,1046const __DRIextension **loader_extensions,1047const __DRIextension **driver_extensions,1048const __DRIconfig ***driver_configs,1049void *loaderPrivate);10501051};10521053/** Common DRI function definitions, shared among DRI2 and Image extensions1054*/10551056typedef __DRIscreen *1057(*__DRIcreateNewScreen2Func)(int screen, int fd,1058const __DRIextension **extensions,1059const __DRIextension **driver_extensions,1060const __DRIconfig ***driver_configs,1061void *loaderPrivate);10621063typedef __DRIdrawable *1064(*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,1065const __DRIconfig *config,1066void *loaderPrivate);10671068typedef __DRIcontext *1069(*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,1070int api,1071const __DRIconfig *config,1072__DRIcontext *shared,1073unsigned num_attribs,1074const uint32_t *attribs,1075unsigned *error,1076void *loaderPrivate);10771078typedef unsigned int1079(*__DRIgetAPIMaskFunc)(__DRIscreen *screen);10801081/**1082* DRI2 Loader extension.1083*/1084#define __DRI_BUFFER_FRONT_LEFT 01085#define __DRI_BUFFER_BACK_LEFT 11086#define __DRI_BUFFER_FRONT_RIGHT 21087#define __DRI_BUFFER_BACK_RIGHT 31088#define __DRI_BUFFER_DEPTH 41089#define __DRI_BUFFER_STENCIL 51090#define __DRI_BUFFER_ACCUM 61091#define __DRI_BUFFER_FAKE_FRONT_LEFT 71092#define __DRI_BUFFER_FAKE_FRONT_RIGHT 81093#define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */1094#define __DRI_BUFFER_HIZ 1010951096/* Inofficial and for internal use. Increase when adding a new buffer token. */1097#define __DRI_BUFFER_COUNT 1110981099struct __DRIbufferRec {1100unsigned int attachment;1101unsigned int name;1102unsigned int pitch;1103unsigned int cpp;1104unsigned int flags;1105};11061107#define __DRI_DRI2_LOADER "DRI_DRI2Loader"1108#define __DRI_DRI2_LOADER_VERSION 511091110enum dri_loader_cap {1111/* Whether the loader handles RGBA channel ordering correctly. If not,1112* only BGRA ordering can be exposed.1113*/1114DRI_LOADER_CAP_RGBA_ORDERING,1115DRI_LOADER_CAP_FP16,1116};11171118struct __DRIdri2LoaderExtensionRec {1119__DRIextension base;11201121__DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,1122int *width, int *height,1123unsigned int *attachments, int count,1124int *out_count, void *loaderPrivate);11251126/**1127* Flush pending front-buffer rendering1128*1129* Any rendering that has been performed to the1130* \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the1131* \c __DRI_BUFFER_FRONT_LEFT.1132*1133* \param driDrawable Drawable whose front-buffer is to be flushed1134* \param loaderPrivate Loader's private data that was previously passed1135* into __DRIdri2ExtensionRec::createNewDrawable1136*1137* \since 21138*/1139void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);114011411142/**1143* Get list of buffers from the server1144*1145* Gets a list of buffer for the specified set of attachments. Unlike1146* \c ::getBuffers, this function takes a list of attachments paired with1147* opaque \c unsigned \c int value describing the format of the buffer.1148* It is the responsibility of the caller to know what the service that1149* allocates the buffers will expect to receive for the format.1150*1151* \param driDrawable Drawable whose buffers are being queried.1152* \param width Output where the width of the buffers is stored.1153* \param height Output where the height of the buffers is stored.1154* \param attachments List of pairs of attachment ID and opaque format1155* requested for the drawable.1156* \param count Number of attachment / format pairs stored in1157* \c attachments.1158* \param loaderPrivate Loader's private data that was previously passed1159* into __DRIdri2ExtensionRec::createNewDrawable.1160*1161* \since 31162*/1163__DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,1164int *width, int *height,1165unsigned int *attachments, int count,1166int *out_count, void *loaderPrivate);11671168/**1169* Return a loader capability value. If the loader doesn't know the enum,1170* it will return 0.1171*1172* \param loaderPrivate The last parameter of createNewScreen or1173* createNewScreen2.1174* \param cap See the enum.1175*1176* \since 41177*/1178unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);11791180/**1181* Clean up any loader state associated with an image.1182*1183* \param loaderPrivate Loader's private data that was previously passed1184* into a __DRIimageExtensionRec::createImage function1185* \since 51186*/1187void (*destroyLoaderImageState)(void *loaderPrivate);1188};11891190/**1191* This extension provides alternative screen, drawable and context1192* constructors for DRI2.1193*/1194#define __DRI_DRI2 "DRI_DRI2"1195#define __DRI_DRI2_VERSION 411961197#define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */1198#define __DRI_API_GLES 1 /**< OpenGL ES 1.x */1199#define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */1200#define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */1201#define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */12021203#define __DRI_CTX_ATTRIB_MAJOR_VERSION 01204#define __DRI_CTX_ATTRIB_MINOR_VERSION 11205#define __DRI_CTX_ATTRIB_FLAGS 212061207/**1208* \requires __DRI2_ROBUSTNESS.1209*/1210#define __DRI_CTX_ATTRIB_RESET_STRATEGY 312111212#define __DRI_CTX_FLAG_DEBUG 0x000000011213#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x0000000212141215/**1216* \requires __DRI2_ROBUSTNESS.1217*/1218#define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x0000000412191220/**1221* \requires __DRI2_NO_ERROR.1222*1223*/1224#define __DRI_CTX_FLAG_NO_ERROR 0x0000000812251226/**1227* \name Context reset strategies.1228*/1229/*@{*/1230#define __DRI_CTX_RESET_NO_NOTIFICATION 01231#define __DRI_CTX_RESET_LOSE_CONTEXT 11232/*@}*/12331234#define __DRI_CTX_ATTRIB_PRIORITY 412351236#define __DRI_CTX_PRIORITY_LOW 01237#define __DRI_CTX_PRIORITY_MEDIUM 11238#define __DRI_CTX_PRIORITY_HIGH 212391240/**1241* \name Context release behaviors.1242*/1243/*@{*/1244#define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR 512451246#define __DRI_CTX_RELEASE_BEHAVIOR_NONE 01247#define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH 11248/*@}*/12491250/**1251* \name Reasons that __DRIdri2Extension::createContextAttribs might fail1252*/1253/*@{*/1254/** Success! */1255#define __DRI_CTX_ERROR_SUCCESS 012561257/** Memory allocation failure */1258#define __DRI_CTX_ERROR_NO_MEMORY 112591260/** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */1261#define __DRI_CTX_ERROR_BAD_API 212621263/** Client requested an API version that the driver can't do. */1264#define __DRI_CTX_ERROR_BAD_VERSION 312651266/** Client requested a flag or combination of flags the driver can't do. */1267#define __DRI_CTX_ERROR_BAD_FLAG 412681269/** Client requested an attribute the driver doesn't understand. */1270#define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 512711272/** Client requested a flag the driver doesn't understand. */1273#define __DRI_CTX_ERROR_UNKNOWN_FLAG 61274/*@}*/12751276struct __DRIdri2ExtensionRec {1277__DRIextension base;12781279__DRIscreen *(*createNewScreen)(int screen, int fd,1280const __DRIextension **extensions,1281const __DRIconfig ***driver_configs,1282void *loaderPrivate);12831284__DRIcreateNewDrawableFunc createNewDrawable;1285__DRIcontext *(*createNewContext)(__DRIscreen *screen,1286const __DRIconfig *config,1287__DRIcontext *shared,1288void *loaderPrivate);12891290/* Since version 2 */1291__DRIgetAPIMaskFunc getAPIMask;12921293__DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,1294int api,1295const __DRIconfig *config,1296__DRIcontext *shared,1297void *data);12981299__DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,1300unsigned int attachment,1301unsigned int format,1302int width,1303int height);1304void (*releaseBuffer)(__DRIscreen *screen,1305__DRIbuffer *buffer);13061307/**1308* Create a context for a particular API with a set of attributes1309*1310* \since version 31311*1312* \sa __DRIswrastExtensionRec::createContextAttribs1313*/1314__DRIcreateContextAttribsFunc createContextAttribs;13151316/**1317* createNewScreen with the driver's extension list passed in.1318*1319* \since version 41320*/1321__DRIcreateNewScreen2Func createNewScreen2;1322};132313241325/**1326* This extension provides functionality to enable various EGLImage1327* extensions.1328*/1329#define __DRI_IMAGE "DRI_IMAGE"1330#define __DRI_IMAGE_VERSION 1913311332/**1333* These formats correspond to the similarly named MESA_FORMAT_*1334* tokens, except in the native endian of the CPU. For example, on1335* little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to1336* MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.1337*1338* __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable1339* by the driver (YUV planar formats) but serve as a base image for1340* creating sub-images for the different planes within the image.1341*1342* R8, GR88 and NONE should not be used with createImageFromName or1343* createImage, and are returned by query from sub images created with1344* createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).1345*/1346#define __DRI_IMAGE_FORMAT_RGB565 0x10011347#define __DRI_IMAGE_FORMAT_XRGB8888 0x10021348#define __DRI_IMAGE_FORMAT_ARGB8888 0x10031349#define __DRI_IMAGE_FORMAT_ABGR8888 0x10041350#define __DRI_IMAGE_FORMAT_XBGR8888 0x10051351#define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */1352#define __DRI_IMAGE_FORMAT_GR88 0x10071353#define __DRI_IMAGE_FORMAT_NONE 0x10081354#define __DRI_IMAGE_FORMAT_XRGB2101010 0x10091355#define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a1356#define __DRI_IMAGE_FORMAT_SARGB8 0x100b1357#define __DRI_IMAGE_FORMAT_ARGB1555 0x100c1358#define __DRI_IMAGE_FORMAT_R16 0x100d1359#define __DRI_IMAGE_FORMAT_GR1616 0x100e1360#define __DRI_IMAGE_FORMAT_YUYV 0x100f1361#define __DRI_IMAGE_FORMAT_XBGR2101010 0x10101362#define __DRI_IMAGE_FORMAT_ABGR2101010 0x10111363#define __DRI_IMAGE_FORMAT_SABGR8 0x10121364#define __DRI_IMAGE_FORMAT_UYVY 0x10131365#define __DRI_IMAGE_FORMAT_XBGR16161616F 0x10141366#define __DRI_IMAGE_FORMAT_ABGR16161616F 0x10151367#define __DRI_IMAGE_FORMAT_SXRGB8 0x10161368#define __DRI_IMAGE_FORMAT_ABGR16161616 0x101713691370#define __DRI_IMAGE_USE_SHARE 0x00011371#define __DRI_IMAGE_USE_SCANOUT 0x00021372#define __DRI_IMAGE_USE_CURSOR 0x0004 /* Deprecated */1373#define __DRI_IMAGE_USE_LINEAR 0x00081374/* The buffer will only be read by an external process after SwapBuffers,1375* in contrary to gbm buffers, front buffers and fake front buffers, which1376* could be read after a flush."1377*/1378#define __DRI_IMAGE_USE_BACKBUFFER 0x00101379#define __DRI_IMAGE_USE_PROTECTED 0x0020138013811382#define __DRI_IMAGE_TRANSFER_READ 0x11383#define __DRI_IMAGE_TRANSFER_WRITE 0x21384#define __DRI_IMAGE_TRANSFER_READ_WRITE \1385(__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)13861387/**1388* Extra fourcc formats used internally to Mesa with createImageFromNames.1389* The externally-available fourccs are defined by drm_fourcc.h (DRM_FORMAT_*)1390* and WL_DRM_FORMAT_* from wayland_drm.h.1391*1392* \since 51393*/13941395#define __DRI_IMAGE_FOURCC_SARGB8888 0x833242581396#define __DRI_IMAGE_FOURCC_SABGR8888 0x843242581397#define __DRI_IMAGE_FOURCC_SXRGB8888 0x853242581398#define __DRI_IMAGE_FOURCC_RGBA16161616 0x38344152 /* fourcc_code('R', 'A', '4', '8' ) */13991400/**1401* Queryable on images created by createImageFromNames.1402*1403* RGB and RGBA might be usable directly as images, but it's still1404* recommended to call fromPlanar with plane == 0.1405*1406* Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create1407* usable sub-images, sampling from images return raw YUV data and1408* color conversion needs to be done in the shader.1409*1410* \since 51411*/14121413#define __DRI_IMAGE_COMPONENTS_RGB 0x30011414#define __DRI_IMAGE_COMPONENTS_RGBA 0x30021415#define __DRI_IMAGE_COMPONENTS_Y_U_V 0x30031416#define __DRI_IMAGE_COMPONENTS_Y_UV 0x30041417#define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x30051418#define __DRI_IMAGE_COMPONENTS_Y_UXVX 0x30081419#define __DRI_IMAGE_COMPONENTS_AYUV 0x30091420#define __DRI_IMAGE_COMPONENTS_XYUV 0x300A1421#define __DRI_IMAGE_COMPONENTS_R 0x30061422#define __DRI_IMAGE_COMPONENTS_RG 0x3007142314241425/**1426* queryImage attributes1427*/14281429#define __DRI_IMAGE_ATTRIB_STRIDE 0x20001430#define __DRI_IMAGE_ATTRIB_HANDLE 0x20011431#define __DRI_IMAGE_ATTRIB_NAME 0x20021432#define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */1433#define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */1434#define __DRI_IMAGE_ATTRIB_HEIGHT 0x20051435#define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */1436#define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions1437* 7+. Each query will return a1438* new fd. */1439#define __DRI_IMAGE_ATTRIB_FOURCC 0x2008 /* available in versions 11 */1440#define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */14411442#define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */1443#define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */1444#define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */14451446enum __DRIYUVColorSpace {1447__DRI_YUV_COLOR_SPACE_UNDEFINED = 0,1448__DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,1449__DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,1450__DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x32811451};14521453enum __DRISampleRange {1454__DRI_YUV_RANGE_UNDEFINED = 0,1455__DRI_YUV_FULL_RANGE = 0x3282,1456__DRI_YUV_NARROW_RANGE = 0x32831457};14581459enum __DRIChromaSiting {1460__DRI_YUV_CHROMA_SITING_UNDEFINED = 0,1461__DRI_YUV_CHROMA_SITING_0 = 0x3284,1462__DRI_YUV_CHROMA_SITING_0_5 = 0x32851463};14641465/**1466* \name Reasons that __DRIimageExtensionRec::createImageFromTexture or1467* __DRIimageExtensionRec::createImageFromDmaBufs might fail1468*/1469/*@{*/1470/** Success! */1471#define __DRI_IMAGE_ERROR_SUCCESS 014721473/** Memory allocation failure */1474#define __DRI_IMAGE_ERROR_BAD_ALLOC 114751476/** Client requested an invalid attribute */1477#define __DRI_IMAGE_ERROR_BAD_MATCH 214781479/** Client requested an invalid texture object */1480#define __DRI_IMAGE_ERROR_BAD_PARAMETER 314811482/** Client requested an invalid pitch and/or offset */1483#define __DRI_IMAGE_ERROR_BAD_ACCESS 41484/*@}*/14851486/**1487* \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities1488*/1489/*@{*/1490#define __DRI_IMAGE_CAP_GLOBAL_NAMES 11491/*@}*/14921493/**1494* blitImage flags1495*/14961497#define __BLIT_FLAG_FLUSH 0x00011498#define __BLIT_FLAG_FINISH 0x000214991500/**1501* Flags for createImageFromDmaBufs31502*/1503#define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x0000000115041505/**1506* queryDmaBufFormatModifierAttribs attributes1507*/15081509/* Available in version 16 */1510#define __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT 0x000115111512typedef struct __DRIimageRec __DRIimage;1513typedef struct __DRIimageExtensionRec __DRIimageExtension;1514struct __DRIimageExtensionRec {1515__DRIextension base;15161517__DRIimage *(*createImageFromName)(__DRIscreen *screen,1518int width, int height, int format,1519int name, int pitch,1520void *loaderPrivate);15211522/* Deprecated since version 17; see createImageFromRenderbuffer2 */1523__DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,1524int renderbuffer,1525void *loaderPrivate);15261527void (*destroyImage)(__DRIimage *image);15281529__DRIimage *(*createImage)(__DRIscreen *screen,1530int width, int height, int format,1531unsigned int use,1532void *loaderPrivate);15331534GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);15351536/**1537* The new __DRIimage will share the content with the old one, see dup(2).1538*/1539__DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);15401541/**1542* Validate that a __DRIimage can be used a certain way.1543*1544* \since 21545*/1546GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);15471548/**1549* Unlike createImageFromName __DRI_IMAGE_FORMAT is not used but instead1550* DRM_FORMAT_*, and strides are in bytes not pixels. Stride is1551* also per block and not per pixel (for non-RGB, see gallium blocks).1552*1553* \since 51554*/1555__DRIimage *(*createImageFromNames)(__DRIscreen *screen,1556int width, int height, int fourcc,1557int *names, int num_names,1558int *strides, int *offsets,1559void *loaderPrivate);15601561/**1562* Create an image out of a sub-region of a parent image. This1563* entry point lets us create individual __DRIimages for different1564* planes in a planar buffer (typically yuv), for example. While a1565* sub-image shares the underlying buffer object with the parent1566* image and other sibling sub-images, the life times of parent and1567* sub-images are not dependent. Destroying the parent or a1568* sub-image doesn't affect other images. The underlying buffer1569* object is free when no __DRIimage remains that references it.1570*1571* Sub-images may overlap, but rendering to overlapping sub-images1572* is undefined.1573*1574* \since 51575*/1576__DRIimage *(*fromPlanar)(__DRIimage *image, int plane,1577void *loaderPrivate);15781579/**1580* Create image from texture.1581*1582* \since 61583*/1584__DRIimage *(*createImageFromTexture)(__DRIcontext *context,1585int target,1586unsigned texture,1587int depth,1588int level,1589unsigned *error,1590void *loaderPrivate);1591/**1592* Like createImageFromNames, but takes a prime fd instead.1593*1594* \since 71595*/1596__DRIimage *(*createImageFromFds)(__DRIscreen *screen,1597int width, int height, int fourcc,1598int *fds, int num_fds,1599int *strides, int *offsets,1600void *loaderPrivate);16011602/**1603* Like createImageFromFds, but takes additional attributes.1604*1605* For EGL_EXT_image_dma_buf_import.1606*1607* \since 81608*/1609__DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,1610int width, int height, int fourcc,1611int *fds, int num_fds,1612int *strides, int *offsets,1613enum __DRIYUVColorSpace color_space,1614enum __DRISampleRange sample_range,1615enum __DRIChromaSiting horiz_siting,1616enum __DRIChromaSiting vert_siting,1617unsigned *error,1618void *loaderPrivate);16191620/**1621* Blit a part of a __DRIimage to another and flushes1622*1623* flush_flag:1624* 0: no flush1625* __BLIT_FLAG_FLUSH: flush after the blit operation1626* __BLIT_FLAG_FINISH: flush and wait the blit finished1627*1628* \since 91629*/1630void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,1631int dstx0, int dsty0, int dstwidth, int dstheight,1632int srcx0, int srcy0, int srcwidth, int srcheight,1633int flush_flag);16341635/**1636* Query for general capabilities of the driver that concern1637* buffer sharing and image importing.1638*1639* \since 101640*/1641int (*getCapabilities)(__DRIscreen *screen);16421643/**1644* Returns a map of the specified region of a __DRIimage for the specified usage.1645*1646* flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the1647* mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ1648* is not included in the flags, the buffer content at map time is1649* undefined. Users wanting to modify the mapping must include1650* __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not1651* included, behaviour when writing the mapping is undefined.1652*1653* Returns the byte stride in *stride, and an opaque pointer to data1654* tracking the mapping in **data, which must be passed to unmapImage().1655*1656* \since 121657*/1658void *(*mapImage)(__DRIcontext *context, __DRIimage *image,1659int x0, int y0, int width, int height,1660unsigned int flags, int *stride, void **data);16611662/**1663* Unmap a previously mapped __DRIimage1664*1665* \since 121666*/1667void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);166816691670/**1671* Creates an image with implementation's favorite modifiers.1672*1673* This acts like createImage except there is a list of modifiers passed in1674* which the implementation may selectively use to create the DRIimage. The1675* result should be the implementation selects one modifier (perhaps it would1676* hold on to a few and later pick).1677*1678* The created image should be destroyed with destroyImage().1679*1680* Returns the new DRIimage. The chosen modifier can be obtained later on1681* and passed back to things like the kernel's AddFB2 interface.1682*1683* \sa __DRIimageRec::createImage1684*1685* \since 141686*/1687__DRIimage *(*createImageWithModifiers)(__DRIscreen *screen,1688int width, int height, int format,1689const uint64_t *modifiers,1690const unsigned int modifier_count,1691void *loaderPrivate);16921693/*1694* Like createImageFromDmaBufs, but takes also format modifiers.1695*1696* For EGL_EXT_image_dma_buf_import_modifiers.1697*1698* \since 151699*/1700__DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen,1701int width, int height, int fourcc,1702uint64_t modifier,1703int *fds, int num_fds,1704int *strides, int *offsets,1705enum __DRIYUVColorSpace color_space,1706enum __DRISampleRange sample_range,1707enum __DRIChromaSiting horiz_siting,1708enum __DRIChromaSiting vert_siting,1709unsigned *error,1710void *loaderPrivate);17111712/*1713* dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers.1714*1715* \param max Maximum number of formats that can be accomodated into1716* \param formats. If zero, no formats are returned -1717* instead, the driver returns the total number of1718* supported dmabuf formats in \param count.1719* \param formats Buffer to fill formats into.1720* \param count Count of formats returned, or, total number of1721* supported formats in case \param max is zero.1722*1723* Returns true on success.1724*1725* \since 151726*/1727GLboolean (*queryDmaBufFormats)(__DRIscreen *screen, int max,1728int *formats, int *count);17291730/*1731* dmabuf format modifier query for a given format to support1732* EGL_EXT_image_dma_buf_import_modifiers.1733*1734* \param fourcc The format to query modifiers for. If this format1735* is not supported by the driver, return false.1736* \param max Maximum number of modifiers that can be accomodated in1737* \param modifiers. If zero, no modifiers are returned -1738* instead, the driver returns the total number of1739* modifiers for \param format in \param count.1740* \param modifiers Buffer to fill modifiers into.1741* \param count Count of the modifiers returned, or, total number of1742* supported modifiers for \param fourcc in case1743* \param max is zero.1744*1745* Returns true upon success.1746*1747* \since 151748*/1749GLboolean (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc,1750int max, uint64_t *modifiers,1751unsigned int *external_only,1752int *count);17531754/**1755* dmabuf format modifier attribute query for a given format and modifier.1756*1757* \param fourcc The format to query. If this format is not supported by1758* the driver, return false.1759* \param modifier The modifier to query. If this format+modifier is not1760* supported by the driver, return false.1761* \param attrib The __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB to query.1762* \param value A pointer to where to store the result of the query.1763*1764* Returns true upon success.1765*1766* \since 161767*/1768GLboolean (*queryDmaBufFormatModifierAttribs)(__DRIscreen *screen,1769uint32_t fourcc, uint64_t modifier,1770int attrib, uint64_t *value);17711772/**1773* Create a DRI image from the given renderbuffer.1774*1775* \param context the current DRI context1776* \param renderbuffer the GL name of the renderbuffer1777* \param loaderPrivate for callbacks into the loader related to the image1778* \param error will be set to one of __DRI_IMAGE_ERROR_xxx1779* \return the newly created image on success, or NULL otherwise1780*1781* \since 171782*/1783__DRIimage *(*createImageFromRenderbuffer2)(__DRIcontext *context,1784int renderbuffer,1785void *loaderPrivate,1786unsigned *error);17871788/*1789* Like createImageFromDmaBufs2, but with an added flags parameter.1790*1791* See __DRI_IMAGE_*_FLAG for valid definitions of flags.1792*1793* \since 181794*/1795__DRIimage *(*createImageFromDmaBufs3)(__DRIscreen *screen,1796int width, int height, int fourcc,1797uint64_t modifier,1798int *fds, int num_fds,1799int *strides, int *offsets,1800enum __DRIYUVColorSpace color_space,1801enum __DRISampleRange sample_range,1802enum __DRIChromaSiting horiz_siting,1803enum __DRIChromaSiting vert_siting,1804uint32_t flags,1805unsigned *error,1806void *loaderPrivate);18071808/**1809* Creates an image with implementation's favorite modifiers and the1810* provided usage flags.1811*1812* This acts like createImageWithModifiers except usage is also specified.1813*1814* The created image should be destroyed with destroyImage().1815*1816* Returns the new DRIimage. The chosen modifier can be obtained later on1817* and passed back to things like the kernel's AddFB2 interface.1818*1819* \sa __DRIimageRec::createImage1820*1821* \since 191822*/1823__DRIimage *(*createImageWithModifiers2)(__DRIscreen *screen,1824int width, int height, int format,1825const uint64_t *modifiers,1826const unsigned int modifier_count,1827unsigned int use,1828void *loaderPrivate);1829};183018311832/**1833* This extension must be implemented by the loader and passed to the1834* driver at screen creation time. The EGLImage entry points in the1835* various client APIs take opaque EGLImage handles and use this1836* extension to map them to a __DRIimage. At version 1, this1837* extensions allows mapping EGLImage pointers to __DRIimage pointers,1838* but future versions could support other EGLImage-like, opaque types1839* with new lookup functions.1840*/1841#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"1842#define __DRI_IMAGE_LOOKUP_VERSION 118431844typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;1845struct __DRIimageLookupExtensionRec {1846__DRIextension base;18471848__DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,1849void *loaderPrivate);1850};18511852/**1853* This extension allows for common DRI2 options1854*/1855#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"1856#define __DRI2_CONFIG_QUERY_VERSION 218571858typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;1859struct __DRI2configQueryExtensionRec {1860__DRIextension base;18611862int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);1863int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);1864int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);1865int (*configQuerys)(__DRIscreen *screen, const char *var, char **val);1866};18671868/**1869* Robust context driver extension.1870*1871* Existence of this extension means the driver can accept the1872* \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the1873* \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in1874* \c __DRIdri2ExtensionRec::createContextAttribs.1875*/1876#define __DRI2_ROBUSTNESS "DRI_Robustness"1877#define __DRI2_ROBUSTNESS_VERSION 118781879typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;1880struct __DRIrobustnessExtensionRec {1881__DRIextension base;1882};18831884/**1885* No-error context driver extension.1886*1887* Existence of this extension means the driver can accept the1888* __DRI_CTX_FLAG_NO_ERROR flag.1889*/1890#define __DRI2_NO_ERROR "DRI_NoError"1891#define __DRI2_NO_ERROR_VERSION 118921893typedef struct __DRInoErrorExtensionRec {1894__DRIextension base;1895} __DRInoErrorExtension;18961897/*1898* Flush control driver extension.1899*1900* Existence of this extension means the driver can accept the1901* \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in1902* \c __DRIdri2ExtensionRec::createContextAttribs.1903*/1904#define __DRI2_FLUSH_CONTROL "DRI_FlushControl"1905#define __DRI2_FLUSH_CONTROL_VERSION 119061907typedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension;1908struct __DRI2flushControlExtensionRec {1909__DRIextension base;1910};19111912/**1913* DRI config options extension.1914*1915* This extension provides the XML string containing driver options for use by1916* the loader in supporting the driconf application.1917*1918* v2:1919* - Add the getXml getter function which allows the driver more flexibility in1920* how the XML is provided.1921* - Deprecate the direct xml pointer. It is only provided as a fallback for1922* older versions of libGL and must not be used by clients that are aware of1923* the newer version. Future driver versions may set it to NULL.1924*/1925#define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"1926#define __DRI_CONFIG_OPTIONS_VERSION 219271928typedef struct __DRIconfigOptionsExtensionRec {1929__DRIextension base;1930const char *xml; /**< deprecated since v2, use getXml instead */19311932/**1933* Get an XML string that describes available driver options for use by a1934* config application.1935*1936* The returned string must be heap-allocated. The caller is responsible for1937* freeing it.1938*/1939char *(*getXml)(const char *driver_name);1940} __DRIconfigOptionsExtension;19411942/**1943* This extension provides a driver vtable to a set of common driver helper1944* functions (driCoreExtension, driDRI2Extension) within the driver1945* implementation, as opposed to having to pass them through a global1946* variable.1947*1948* It is not intended to be public API to the actual loader, and the vtable1949* layout may change at any time.1950*/1951#define __DRI_DRIVER_VTABLE "DRI_DriverVtable"1952#define __DRI_DRIVER_VTABLE_VERSION 119531954typedef struct __DRIDriverVtableExtensionRec {1955__DRIextension base;1956const struct __DriverAPIRec *vtable;1957} __DRIDriverVtableExtension;19581959/**1960* Query renderer driver extension1961*1962* This allows the window system layer (either EGL or GLX) to query aspects of1963* hardware and driver support without creating a context.1964*/1965#define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"1966#define __DRI2_RENDERER_QUERY_VERSION 119671968#define __DRI2_RENDERER_VENDOR_ID 0x00001969#define __DRI2_RENDERER_DEVICE_ID 0x00011970#define __DRI2_RENDERER_VERSION 0x00021971#define __DRI2_RENDERER_ACCELERATED 0x00031972#define __DRI2_RENDERER_VIDEO_MEMORY 0x00041973#define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x00051974#define __DRI2_RENDERER_PREFERRED_PROFILE 0x00061975#define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x00071976#define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x00081977#define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x00091978#define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a1979#define __DRI2_RENDERER_HAS_TEXTURE_3D 0x000b1980/* Whether there is an sRGB format support for every supported 32-bit UNORM1981* color format.1982*/1983#define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c19841985/* Bitmaks of supported/available context priorities - must match1986* __EGL_CONTEXT_PRIORITY_LOW_BIT et al1987*/1988#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY 0x000d1989#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW (1 << 0)1990#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1)1991#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2)19921993#define __DRI2_RENDERER_HAS_PROTECTED_CONTENT 0x000e19941995typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;1996struct __DRI2rendererQueryExtensionRec {1997__DRIextension base;19981999int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);2000int (*queryString)(__DRIscreen *screen, int attribute, const char **val);2001};20022003/**2004* Image Loader extension. Drivers use this to allocate color buffers2005*/20062007/**2008* See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask.2009*/2010enum __DRIimageBufferMask {2011__DRI_IMAGE_BUFFER_BACK = (1 << 0),2012__DRI_IMAGE_BUFFER_FRONT = (1 << 1),20132014/**2015* A buffer shared between application and compositor. The buffer may be2016* simultaneously accessed by each.2017*2018* A shared buffer is equivalent to an EGLSurface whose EGLConfig contains2019* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as2020* opposed to any pending, requested change to EGL_RENDER_BUFFER) is2021* EGL_SINGLE_BUFFER.2022*2023* If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no2024* other bits. As a corollary, a __DRIdrawable that has a "shared" buffer2025* has no front nor back buffer.2026*2027* The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only2028* if:2029* - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER.2030* - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER.2031* - The EGLConfig of the drawable EGLSurface contains2032* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.2033* - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER.2034* Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as2035* opposed to any pending, requested change to EGL_RENDER_BUFFER) is2036* EGL_SINGLE_BUFFER. (See the EGL 1.5 and2037* EGL_KHR_mutable_render_buffer spec for details about "pending" vs2038* "active" EGL_RENDER_BUFFER state).2039*2040* A shared buffer is similar to a front buffer in that all rendering to the2041* buffer should appear promptly on the screen. It is different from2042* a front buffer in that its behavior is independent from the2043* GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the2044* __DRIdrawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all2045* rendering should appear promptly on the screen if GL_DRAW_BUFFER is not2046* GL_NONE.2047*2048* The difference between a shared buffer and a front buffer is motivated2049* by the constraints of Android and OpenGL ES. OpenGL ES does not support2050* front-buffer rendering. Android's SurfaceFlinger protocol provides the2051* EGL driver only a back buffer and no front buffer. The shared buffer2052* mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though2053* EGL that allows Android OpenGL ES applications to render to what is2054* effectively the front buffer, a backdoor that required no change to the2055* OpenGL ES API and little change to the SurfaceFlinger API.2056*/2057__DRI_IMAGE_BUFFER_SHARED = (1 << 2),2058};20592060struct __DRIimageList {2061uint32_t image_mask;2062__DRIimage *back;2063__DRIimage *front;2064};20652066#define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"2067#define __DRI_IMAGE_LOADER_VERSION 420682069struct __DRIimageLoaderExtensionRec {2070__DRIextension base;20712072/**2073* Allocate color buffers.2074*2075* \param driDrawable2076* \param width Width of allocated buffers2077* \param height Height of allocated buffers2078* \param format one of __DRI_IMAGE_FORMAT_*2079* \param stamp Address of variable to be updated when2080* getBuffers must be called again2081* \param loaderPrivate The loaderPrivate for driDrawable2082* \param buffer_mask Set of buffers to allocate. A bitmask of2083* __DRIimageBufferMask.2084* \param buffers Returned buffers2085*/2086int (*getBuffers)(__DRIdrawable *driDrawable,2087unsigned int format,2088uint32_t *stamp,2089void *loaderPrivate,2090uint32_t buffer_mask,2091struct __DRIimageList *buffers);20922093/**2094* Flush pending front-buffer rendering2095*2096* Any rendering that has been performed to the2097* fake front will be flushed to the front2098*2099* \param driDrawable Drawable whose front-buffer is to be flushed2100* \param loaderPrivate Loader's private data that was previously passed2101* into __DRIdri2ExtensionRec::createNewDrawable2102*/2103void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);21042105/**2106* Return a loader capability value. If the loader doesn't know the enum,2107* it will return 0.2108*2109* \since 22110*/2111unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);21122113/**2114* Flush swap buffers2115*2116* Make sure any outstanding swap buffers have been submitted to the2117* device.2118*2119* \param driDrawable Drawable whose swaps need to be flushed2120* \param loaderPrivate Loader's private data that was previously passed2121* into __DRIdri2ExtensionRec::createNewDrawable2122*2123* \since 32124*/2125void (*flushSwapBuffers)(__DRIdrawable *driDrawable, void *loaderPrivate);21262127/**2128* Clean up any loader state associated with an image.2129*2130* \param loaderPrivate Loader's private data that was previously passed2131* into a __DRIimageExtensionRec::createImage function2132* \since 42133*/2134void (*destroyLoaderImageState)(void *loaderPrivate);2135};21362137/**2138* DRI extension.2139*/21402141#define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"2142#define __DRI_IMAGE_DRIVER_VERSION 121432144struct __DRIimageDriverExtensionRec {2145__DRIextension base;21462147/* Common DRI functions, shared with DRI2 */2148__DRIcreateNewScreen2Func createNewScreen2;2149__DRIcreateNewDrawableFunc createNewDrawable;2150__DRIcreateContextAttribsFunc createContextAttribs;2151__DRIgetAPIMaskFunc getAPIMask;2152};21532154/**2155* Background callable loader extension.2156*2157* Loaders expose this extension to indicate to drivers that they are capable2158* of handling callbacks from the driver's background drawing threads.2159*/2160#define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"2161#define __DRI_BACKGROUND_CALLABLE_VERSION 121622163typedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension;2164struct __DRIbackgroundCallableExtensionRec {2165__DRIextension base;21662167/**2168* Indicate that this thread is being used by the driver as a background2169* drawing thread which may make callbacks to the loader.2170*2171* \param loaderPrivate is the value that was passed to to the driver when2172* the context was created. This can be used by the loader to identify2173* which context any callbacks are associated with.2174*2175* If this function is called more than once from any given thread, each2176* subsequent call overrides the loaderPrivate data that was passed in the2177* previous call. The driver can take advantage of this to re-use a2178* background thread to perform drawing on behalf of multiple contexts.2179*2180* It is permissible for the driver to call this function from a2181* non-background thread (i.e. a thread that has already been bound to a2182* context using __DRIcoreExtensionRec::bindContext()); when this happens,2183* the \c loaderPrivate pointer must be equal to the pointer that was2184* passed to the driver when the currently bound context was created.2185*2186* This call should execute quickly enough that the driver can call it with2187* impunity whenever a background thread starts performing drawing2188* operations (e.g. it should just set a thread-local variable).2189*/2190void (*setBackgroundContext)(void *loaderPrivate);21912192/**2193* Indicate that it is multithread safe to use glthread. For GLX/EGL2194* platforms using Xlib, that involves calling XInitThreads, before2195* opening an X display.2196*2197* Note: only supported if extension version is at least 2.2198*2199* \param loaderPrivate is the value that was passed to to the driver when2200* the context was created. This can be used by the loader to identify2201* which context any callbacks are associated with.2202*/2203GLboolean (*isThreadSafe)(void *loaderPrivate);2204};22052206/**2207* The driver portion of EGL_KHR_mutable_render_buffer.2208*2209* If the driver creates a __DRIconfig with2210* __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension.2211*2212* To support this extension:2213*2214* - The driver should create at least one __DRIconfig with2215* __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but2216* not required.2217*2218* - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if2219* returned by __DRIimageLoaderExtension:getBuffers().2220*2221* - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call2222* __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() in2223* response to glFlush and glFinish. (This requirement is not documented2224* in EGL_KHR_mutable_render_buffer, but is a de-facto requirement in the2225* Android ecosystem. Android applications expect that glFlush will2226* immediately display the buffer when in shared buffer mode, and Android2227* drivers comply with this expectation). It :may: call2228* displaySharedBuffer() more often than required.2229*2230* - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the2231* buffer is always in a format compatible for display because the2232* display engine (usually SurfaceFlinger or hwcomposer) may display the2233* image at any time, even concurrently with 3D rendering. For example,2234* display hardware and the GL hardware may be able to access the buffer2235* simultaneously. In particular, if the buffer is compressed then take2236* care that SurfaceFlinger and hwcomposer can consume the compression2237* format.2238*2239* \see __DRI_IMAGE_BUFFER_SHARED2240* \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER2241* \see __DRI_MUTABLE_RENDER_BUFFER_LOADER2242*/2243#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver"2244#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 122452246typedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension;2247struct __DRImutableRenderBufferDriverExtensionRec {2248__DRIextension base;2249};22502251/**2252* The loader portion of EGL_KHR_mutable_render_buffer.2253*2254* Requires loader extension DRI_IMAGE_LOADER, through which the loader sends2255* __DRI_IMAGE_BUFFER_SHARED to the driver.2256*2257* \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER2258*/2259#define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader"2260#define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 122612262typedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension;2263struct __DRImutableRenderBufferLoaderExtensionRec {2264__DRIextension base;22652266/**2267* Inform the display engine (that is, SurfaceFlinger and/or hwcomposer)2268* that the __DRIdrawable has new content.2269*2270* The display engine may ignore this call, for example, if it continually2271* refreshes and displays the buffer on every frame, as in2272* EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display2273* engine may refresh and display the buffer only in frames in which the2274* driver calls this.2275*2276* If the fence_fd is not -1, then the display engine will display the2277* buffer only after the fence signals.2278*2279* The drawable's current __DRIimageBufferMask, as returned by2280* __DRIimageLoaderExtension::getBuffers(), must be2281* __DRI_IMAGE_BUFFER_SHARED.2282*/2283void (*displaySharedBuffer)(__DRIdrawable *drawable, int fence_fd,2284void *loaderPrivate);2285};22862287#endif228822892290