+/**
+ * No-error context driver extension.
+ *
+ * Existence of this extension means the driver can accept the
+ * __DRI_CTX_FLAG_NO_ERROR flag.
+ */
+#define __DRI2_NO_ERROR "DRI_NoError"
+#define __DRI2_NO_ERROR_VERSION 1
+
+typedef struct __DRInoErrorExtensionRec {
+ __DRIextension base;
+} __DRInoErrorExtension;
+
+/*
+ * Flush control driver extension.
+ *
+ * Existence of this extension means the driver can accept the
+ * \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in
+ * \c __DRIdri2ExtensionRec::createContextAttribs.
+ */
+#define __DRI2_FLUSH_CONTROL "DRI_FlushControl"
+#define __DRI2_FLUSH_CONTROL_VERSION 1
+
+typedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension;
+struct __DRI2flushControlExtensionRec {
+ __DRIextension base;
+};
+
+/**
+ * DRI config options extension.
+ *
+ * This extension provides the XML string containing driver options for use by
+ * the loader in supporting the driconf application.
+ *
+ * v2:
+ * - Add the getXml getter function which allows the driver more flexibility in
+ * how the XML is provided.
+ * - Deprecate the direct xml pointer. It is only provided as a fallback for
+ * older versions of libGL and must not be used by clients that are aware of
+ * the newer version. Future driver versions may set it to NULL.
+ */
+#define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
+#define __DRI_CONFIG_OPTIONS_VERSION 2
+
+typedef struct __DRIconfigOptionsExtensionRec {
+ __DRIextension base;
+ const char *xml; /**< deprecated since v2, use getXml instead */
+
+ /**
+ * Get an XML string that describes available driver options for use by a
+ * config application.
+ *
+ * The returned string must be heap-allocated. The caller is responsible for
+ * freeing it.
+ */
+ char *(*getXml)(const char *driver_name);
+} __DRIconfigOptionsExtension;
+
+/**
+ * This extension provides a driver vtable to a set of common driver helper
+ * functions (driCoreExtension, driDRI2Extension) within the driver
+ * implementation, as opposed to having to pass them through a global
+ * variable.
+ *
+ * It is not intended to be public API to the actual loader, and the vtable
+ * layout may change at any time.
+ */
+#define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
+#define __DRI_DRIVER_VTABLE_VERSION 1
+
+typedef struct __DRIDriverVtableExtensionRec {
+ __DRIextension base;
+ const struct __DriverAPIRec *vtable;
+} __DRIDriverVtableExtension;
+
+/**
+ * Query renderer driver extension
+ *
+ * This allows the window system layer (either EGL or GLX) to query aspects of
+ * hardware and driver support without creating a context.
+ */
+#define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
+#define __DRI2_RENDERER_QUERY_VERSION 1
+
+#define __DRI2_RENDERER_VENDOR_ID 0x0000
+#define __DRI2_RENDERER_DEVICE_ID 0x0001
+#define __DRI2_RENDERER_VERSION 0x0002
+#define __DRI2_RENDERER_ACCELERATED 0x0003
+#define __DRI2_RENDERER_VIDEO_MEMORY 0x0004
+#define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005
+#define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006
+#define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007
+#define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008
+#define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009
+#define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a
+#define __DRI2_RENDERER_HAS_TEXTURE_3D 0x000b
+/* Whether there is an sRGB format support for every supported 32-bit UNORM
+ * color format.
+ */
+#define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c
+
+/* Bitmaks of supported/available context priorities - must match
+ * __EGL_CONTEXT_PRIORITY_LOW_BIT et al
+ */
+#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY 0x000d
+#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW (1 << 0)
+#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1)
+#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2)
+
+typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
+struct __DRI2rendererQueryExtensionRec {
+ __DRIextension base;
+
+ int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
+ int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
+};
+
+/**
+ * Image Loader extension. Drivers use this to allocate color buffers
+ */
+
+/**
+ * See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask.
+ */
+enum __DRIimageBufferMask {
+ __DRI_IMAGE_BUFFER_BACK = (1 << 0),
+ __DRI_IMAGE_BUFFER_FRONT = (1 << 1),
+
+ /**
+ * A buffer shared between application and compositor. The buffer may be
+ * simultaneously accessed by each.
+ *
+ * A shared buffer is equivalent to an EGLSurface whose EGLConfig contains
+ * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as
+ * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
+ * EGL_SINGLE_BUFFER.
+ *
+ * If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no
+ * other bits. As a corollary, a __DRIdrawable that has a "shared" buffer
+ * has no front nor back buffer.
+ *
+ * The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only
+ * if:
+ * - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER.
+ * - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER.
+ * - The EGLConfig of the drawable EGLSurface contains
+ * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.
+ * - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER.
+ * Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as
+ * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
+ * EGL_SINGLE_BUFFER. (See the EGL 1.5 and
+ * EGL_KHR_mutable_render_buffer spec for details about "pending" vs
+ * "active" EGL_RENDER_BUFFER state).
+ *
+ * A shared buffer is similar to a front buffer in that all rendering to the
+ * buffer should appear promptly on the screen. It is different from
+ * a front buffer in that its behavior is independent from the
+ * GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the
+ * __DRIdrawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all
+ * rendering should appear promptly on the screen if GL_DRAW_BUFFER is not
+ * GL_NONE.
+ *
+ * The difference between a shared buffer and a front buffer is motivated
+ * by the constraints of Android and OpenGL ES. OpenGL ES does not support
+ * front-buffer rendering. Android's SurfaceFlinger protocol provides the
+ * EGL driver only a back buffer and no front buffer. The shared buffer
+ * mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though
+ * EGL that allows Android OpenGL ES applications to render to what is
+ * effectively the front buffer, a backdoor that required no change to the
+ * OpenGL ES API and little change to the SurfaceFlinger API.
+ */
+ __DRI_IMAGE_BUFFER_SHARED = (1 << 2),
+};
+
+struct __DRIimageList {
+ uint32_t image_mask;
+ __DRIimage *back;
+ __DRIimage *front;
+};
+
+#define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
+#define __DRI_IMAGE_LOADER_VERSION 3
+
+struct __DRIimageLoaderExtensionRec {
+ __DRIextension base;
+
+ /**
+ * Allocate color buffers.
+ *
+ * \param driDrawable
+ * \param width Width of allocated buffers
+ * \param height Height of allocated buffers
+ * \param format one of __DRI_IMAGE_FORMAT_*
+ * \param stamp Address of variable to be updated when
+ * getBuffers must be called again
+ * \param loaderPrivate The loaderPrivate for driDrawable
+ * \param buffer_mask Set of buffers to allocate. A bitmask of
+ * __DRIimageBufferMask.
+ * \param buffers Returned buffers
+ */
+ int (*getBuffers)(__DRIdrawable *driDrawable,
+ unsigned int format,
+ uint32_t *stamp,
+ void *loaderPrivate,
+ uint32_t buffer_mask,
+ struct __DRIimageList *buffers);
+
+ /**
+ * Flush pending front-buffer rendering
+ *
+ * Any rendering that has been performed to the
+ * fake front will be flushed to the front
+ *
+ * \param driDrawable Drawable whose front-buffer is to be flushed
+ * \param loaderPrivate Loader's private data that was previously passed
+ * into __DRIdri2ExtensionRec::createNewDrawable
+ */
+ void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
+
+ /**
+ * Return a loader capability value. If the loader doesn't know the enum,
+ * it will return 0.
+ *
+ * \since 2
+ */
+ unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
+
+ /**
+ * Flush swap buffers
+ *
+ * Make sure any outstanding swap buffers have been submitted to the
+ * device.
+ *
+ * \param driDrawable Drawable whose swaps need to be flushed
+ * \param loaderPrivate Loader's private data that was previously passed
+ * into __DRIdri2ExtensionRec::createNewDrawable
+ *
+ * \since 3
+ */
+ void (*flushSwapBuffers)(__DRIdrawable *driDrawable, void *loaderPrivate);
+};
+
+/**
+ * DRI extension.
+ */
+
+#define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"
+#define __DRI_IMAGE_DRIVER_VERSION 1
+
+struct __DRIimageDriverExtensionRec {
+ __DRIextension base;
+
+ /* Common DRI functions, shared with DRI2 */
+ __DRIcreateNewScreen2Func createNewScreen2;
+ __DRIcreateNewDrawableFunc createNewDrawable;
+ __DRIcreateContextAttribsFunc createContextAttribs;
+ __DRIgetAPIMaskFunc getAPIMask;
+};
+
+/**
+ * Background callable loader extension.
+ *
+ * Loaders expose this extension to indicate to drivers that they are capable
+ * of handling callbacks from the driver's background drawing threads.
+ */
+#define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"
+#define __DRI_BACKGROUND_CALLABLE_VERSION 1
+
+typedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension;
+struct __DRIbackgroundCallableExtensionRec {
+ __DRIextension base;
+
+ /**
+ * Indicate that this thread is being used by the driver as a background
+ * drawing thread which may make callbacks to the loader.
+ *
+ * \param loaderPrivate is the value that was passed to to the driver when
+ * the context was created. This can be used by the loader to identify
+ * which context any callbacks are associated with.
+ *
+ * If this function is called more than once from any given thread, each
+ * subsequent call overrides the loaderPrivate data that was passed in the
+ * previous call. The driver can take advantage of this to re-use a
+ * background thread to perform drawing on behalf of multiple contexts.
+ *
+ * It is permissible for the driver to call this function from a
+ * non-background thread (i.e. a thread that has already been bound to a
+ * context using __DRIcoreExtensionRec::bindContext()); when this happens,
+ * the \c loaderPrivate pointer must be equal to the pointer that was
+ * passed to the driver when the currently bound context was created.
+ *
+ * This call should execute quickly enough that the driver can call it with
+ * impunity whenever a background thread starts performing drawing
+ * operations (e.g. it should just set a thread-local variable).
+ */
+ void (*setBackgroundContext)(void *loaderPrivate);
+
+ /**
+ * Indicate that it is multithread safe to use glthread. For GLX/EGL
+ * platforms using Xlib, that involves calling XInitThreads, before
+ * opening an X display.
+ *
+ * Note: only supported if extension version is at least 2.
+ *
+ * \param loaderPrivate is the value that was passed to to the driver when
+ * the context was created. This can be used by the loader to identify
+ * which context any callbacks are associated with.
+ */
+ GLboolean (*isThreadSafe)(void *loaderPrivate);
+};
+
+/**
+ * The driver portion of EGL_KHR_mutable_render_buffer.
+ *
+ * If the driver creates a __DRIconfig with
+ * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension.
+ *
+ * To support this extension:
+ *
+ * - The driver should create at least one __DRIconfig with
+ * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but
+ * not required.
+ *
+ * - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if
+ * returned by __DRIimageLoaderExtension:getBuffers().
+ *
+ * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call
+ * __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() in
+ * response to glFlush and glFinish. (This requirement is not documented
+ * in EGL_KHR_mutable_render_buffer, but is a de-facto requirement in the
+ * Android ecosystem. Android applications expect that glFlush will
+ * immediately display the buffer when in shared buffer mode, and Android
+ * drivers comply with this expectation). It :may: call
+ * displaySharedBuffer() more often than required.
+ *
+ * - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the
+ * buffer is always in a format compatible for display because the
+ * display engine (usually SurfaceFlinger or hwcomposer) may display the
+ * image at any time, even concurrently with 3D rendering. For example,
+ * display hardware and the GL hardware may be able to access the buffer
+ * simultaneously. In particular, if the buffer is compressed then take
+ * care that SurfaceFlinger and hwcomposer can consume the compression
+ * format.
+ *
+ * \see __DRI_IMAGE_BUFFER_SHARED
+ * \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER
+ * \see __DRI_MUTABLE_RENDER_BUFFER_LOADER
+ */
+#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver"
+#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 1
+
+typedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension;
+struct __DRImutableRenderBufferDriverExtensionRec {
+ __DRIextension base;
+};
+
+/**
+ * The loader portion of EGL_KHR_mutable_render_buffer.
+ *
+ * Requires loader extension DRI_IMAGE_LOADER, through which the loader sends
+ * __DRI_IMAGE_BUFFER_SHARED to the driver.
+ *
+ * \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER
+ */
+#define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader"
+#define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 1
+
+typedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension;
+struct __DRImutableRenderBufferLoaderExtensionRec {
+ __DRIextension base;
+
+ /**
+ * Inform the display engine (that is, SurfaceFlinger and/or hwcomposer)
+ * that the __DRIdrawable has new content.
+ *
+ * The display engine may ignore this call, for example, if it continually
+ * refreshes and displays the buffer on every frame, as in
+ * EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display
+ * engine may refresh and display the buffer only in frames in which the
+ * driver calls this.
+ *
+ * If the fence_fd is not -1, then the display engine will display the
+ * buffer only after the fence signals.
+ *
+ * The drawable's current __DRIimageBufferMask, as returned by
+ * __DRIimageLoaderExtension::getBuffers(), must be
+ * __DRI_IMAGE_BUFFER_SHARED.
+ */
+ void (*displaySharedBuffer)(__DRIdrawable *drawable, int fence_fd,
+ void *loaderPrivate);
+};
+