1848b8605Smrg/*
2848b8605Smrg * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3848b8605Smrg * Copyright 2007-2008 Red Hat, Inc.
4848b8605Smrg * (C) Copyright IBM Corporation 2004
5848b8605Smrg * All Rights Reserved.
6848b8605Smrg *
7848b8605Smrg * Permission is hereby granted, free of charge, to any person obtaining a
8848b8605Smrg * copy of this software and associated documentation files (the "Software"),
9848b8605Smrg * to deal in the Software without restriction, including without limitation
10848b8605Smrg * on the rights to use, copy, modify, merge, publish, distribute, sub
11848b8605Smrg * license, and/or sell copies of the Software, and to permit persons to whom
12848b8605Smrg * the Software is furnished to do so, subject to the following conditions:
13848b8605Smrg *
14848b8605Smrg * The above copyright notice and this permission notice (including the next
15848b8605Smrg * paragraph) shall be included in all copies or substantial portions of the
16848b8605Smrg * Software.
17848b8605Smrg *
18848b8605Smrg * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19848b8605Smrg * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20848b8605Smrg * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
21848b8605Smrg * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22848b8605Smrg * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23848b8605Smrg * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24848b8605Smrg * USE OR OTHER DEALINGS IN THE SOFTWARE.
25848b8605Smrg */
26848b8605Smrg
27848b8605Smrg/**
28848b8605Smrg * \file dri_interface.h
29848b8605Smrg *
30848b8605Smrg * This file contains all the types and functions that define the interface
31848b8605Smrg * between a DRI driver and driver loader.  Currently, the most common driver
32848b8605Smrg * loader is the XFree86 libGL.so.  However, other loaders do exist, and in
33848b8605Smrg * the future the server-side libglx.a will also be a loader.
34848b8605Smrg *
35848b8605Smrg * \author Kevin E. Martin <kevin@precisioninsight.com>
36848b8605Smrg * \author Ian Romanick <idr@us.ibm.com>
37848b8605Smrg * \author Kristian Høgsberg <krh@redhat.com>
38848b8605Smrg */
39848b8605Smrg
40848b8605Smrg#ifndef DRI_INTERFACE_H
41848b8605Smrg#define DRI_INTERFACE_H
42848b8605Smrg
43b8e80941Smrg#ifdef HAVE_LIBDRM
44848b8605Smrg#include <drm.h>
45848b8605Smrg#else
46b8e80941Smrg#ifndef _DRM_H_
47848b8605Smrgtypedef unsigned int drm_context_t;
48848b8605Smrgtypedef unsigned int drm_drawable_t;
49848b8605Smrgtypedef struct drm_clip_rect drm_clip_rect_t;
50848b8605Smrg#endif
51b8e80941Smrg#endif
52b8e80941Smrg
53b8e80941Smrg#include <GL/gl.h>
54b8e80941Smrg
55b8e80941Smrg#include <stdint.h>
56848b8605Smrg
57848b8605Smrg/**
58848b8605Smrg * \name DRI interface structures
59848b8605Smrg *
60848b8605Smrg * The following structures define the interface between the GLX client
61848b8605Smrg * side library and the DRI (direct rendering infrastructure).
62848b8605Smrg */
63848b8605Smrg/*@{*/
64848b8605Smrgtypedef struct __DRIdisplayRec		__DRIdisplay;
65848b8605Smrgtypedef struct __DRIscreenRec		__DRIscreen;
66848b8605Smrgtypedef struct __DRIcontextRec		__DRIcontext;
67848b8605Smrgtypedef struct __DRIdrawableRec		__DRIdrawable;
68848b8605Smrgtypedef struct __DRIconfigRec		__DRIconfig;
69848b8605Smrgtypedef struct __DRIframebufferRec	__DRIframebuffer;
70848b8605Smrgtypedef struct __DRIversionRec		__DRIversion;
71848b8605Smrg
72848b8605Smrgtypedef struct __DRIcoreExtensionRec		__DRIcoreExtension;
73848b8605Smrgtypedef struct __DRIextensionRec		__DRIextension;
74848b8605Smrgtypedef struct __DRIcopySubBufferExtensionRec	__DRIcopySubBufferExtension;
75848b8605Smrgtypedef struct __DRIswapControlExtensionRec	__DRIswapControlExtension;
76848b8605Smrgtypedef struct __DRIframeTrackingExtensionRec	__DRIframeTrackingExtension;
77848b8605Smrgtypedef struct __DRImediaStreamCounterExtensionRec	__DRImediaStreamCounterExtension;
78848b8605Smrgtypedef struct __DRItexOffsetExtensionRec	__DRItexOffsetExtension;
79848b8605Smrgtypedef struct __DRItexBufferExtensionRec	__DRItexBufferExtension;
80848b8605Smrgtypedef struct __DRIlegacyExtensionRec		__DRIlegacyExtension;
81848b8605Smrgtypedef struct __DRIswrastExtensionRec		__DRIswrastExtension;
82848b8605Smrgtypedef struct __DRIbufferRec			__DRIbuffer;
83848b8605Smrgtypedef struct __DRIdri2ExtensionRec		__DRIdri2Extension;
84848b8605Smrgtypedef struct __DRIdri2LoaderExtensionRec	__DRIdri2LoaderExtension;
85848b8605Smrgtypedef struct __DRI2flushExtensionRec	__DRI2flushExtension;
86848b8605Smrgtypedef struct __DRI2throttleExtensionRec	__DRI2throttleExtension;
87b8e80941Smrgtypedef struct __DRI2fenceExtensionRec          __DRI2fenceExtension;
88b8e80941Smrgtypedef struct __DRI2interopExtensionRec	__DRI2interopExtension;
89b8e80941Smrgtypedef struct __DRI2blobExtensionRec           __DRI2blobExtension;
90848b8605Smrg
91848b8605Smrgtypedef struct __DRIimageLoaderExtensionRec     __DRIimageLoaderExtension;
92848b8605Smrgtypedef struct __DRIimageDriverExtensionRec     __DRIimageDriverExtension;
93848b8605Smrg
94848b8605Smrg/*@}*/
95848b8605Smrg
96848b8605Smrg
97848b8605Smrg/**
98848b8605Smrg * Extension struct.  Drivers 'inherit' from this struct by embedding
99848b8605Smrg * it as the first element in the extension struct.
100848b8605Smrg *
101848b8605Smrg * We never break API in for a DRI extension.  If we need to change
102848b8605Smrg * the way things work in a non-backwards compatible manner, we
103848b8605Smrg * introduce a new extension.  During a transition period, we can
104848b8605Smrg * leave both the old and the new extension in the driver, which
105848b8605Smrg * allows us to move to the new interface without having to update the
106848b8605Smrg * loader(s) in lock step.
107848b8605Smrg *
108848b8605Smrg * However, we can add entry points to an extension over time as long
109848b8605Smrg * as we don't break the old ones.  As we add entry points to an
110848b8605Smrg * extension, we increase the version number.  The corresponding
111848b8605Smrg * #define can be used to guard code that accesses the new entry
112848b8605Smrg * points at compile time and the version field in the extension
113848b8605Smrg * struct can be used at run-time to determine how to use the
114848b8605Smrg * extension.
115848b8605Smrg */
116848b8605Smrgstruct __DRIextensionRec {
117848b8605Smrg    const char *name;
118848b8605Smrg    int version;
119848b8605Smrg};
120848b8605Smrg
121848b8605Smrg/**
122848b8605Smrg * The first set of extension are the screen extensions, returned by
123848b8605Smrg * __DRIcore::getExtensions().  This entry point will return a list of
124848b8605Smrg * extensions and the loader can use the ones it knows about by
125848b8605Smrg * casting them to more specific extensions and advertising any GLX
126848b8605Smrg * extensions the DRI extensions enables.
127848b8605Smrg */
128848b8605Smrg
129848b8605Smrg/**
130848b8605Smrg * Used by drivers to indicate support for setting the read drawable.
131848b8605Smrg */
132848b8605Smrg#define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
133848b8605Smrg#define __DRI_READ_DRAWABLE_VERSION 1
134848b8605Smrg
135848b8605Smrg/**
136848b8605Smrg * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
137848b8605Smrg */
138848b8605Smrg#define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
139848b8605Smrg#define __DRI_COPY_SUB_BUFFER_VERSION 1
140848b8605Smrgstruct __DRIcopySubBufferExtensionRec {
141848b8605Smrg    __DRIextension base;
142848b8605Smrg    void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);
143848b8605Smrg};
144848b8605Smrg
145848b8605Smrg/**
146848b8605Smrg * Used by drivers that implement the GLX_SGI_swap_control or
147848b8605Smrg * GLX_MESA_swap_control extension.
148848b8605Smrg */
149848b8605Smrg#define __DRI_SWAP_CONTROL "DRI_SwapControl"
150848b8605Smrg#define __DRI_SWAP_CONTROL_VERSION 1
151848b8605Smrgstruct __DRIswapControlExtensionRec {
152848b8605Smrg    __DRIextension base;
153848b8605Smrg    void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
154848b8605Smrg    unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
155848b8605Smrg};
156848b8605Smrg
157848b8605Smrg/**
158848b8605Smrg * Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
159848b8605Smrg */
160848b8605Smrg#define __DRI_FRAME_TRACKING "DRI_FrameTracking"
161848b8605Smrg#define __DRI_FRAME_TRACKING_VERSION 1
162848b8605Smrgstruct __DRIframeTrackingExtensionRec {
163848b8605Smrg    __DRIextension base;
164848b8605Smrg
165848b8605Smrg    /**
166848b8605Smrg     * Enable or disable frame usage tracking.
167848b8605Smrg     *
168848b8605Smrg     * \since Internal API version 20030317.
169848b8605Smrg     */
170848b8605Smrg    int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable);
171848b8605Smrg
172848b8605Smrg    /**
173848b8605Smrg     * Retrieve frame usage information.
174848b8605Smrg     *
175848b8605Smrg     * \since Internal API version 20030317.
176848b8605Smrg     */
177848b8605Smrg    int (*queryFrameTracking)(__DRIdrawable *drawable,
178848b8605Smrg			      int64_t * sbc, int64_t * missedFrames,
179848b8605Smrg			      float * lastMissedUsage, float * usage);
180848b8605Smrg};
181848b8605Smrg
182848b8605Smrg
183848b8605Smrg/**
184848b8605Smrg * Used by drivers that implement the GLX_SGI_video_sync extension.
185848b8605Smrg */
186848b8605Smrg#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
187848b8605Smrg#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
188848b8605Smrgstruct __DRImediaStreamCounterExtensionRec {
189848b8605Smrg    __DRIextension base;
190848b8605Smrg
191848b8605Smrg    /**
192848b8605Smrg     * Wait for the MSC to equal target_msc, or, if that has already passed,
193848b8605Smrg     * the next time (MSC % divisor) is equal to remainder.  If divisor is
194848b8605Smrg     * zero, the function will return as soon as MSC is greater than or equal
195848b8605Smrg     * to target_msc.
196848b8605Smrg     */
197848b8605Smrg    int (*waitForMSC)(__DRIdrawable *drawable,
198848b8605Smrg		      int64_t target_msc, int64_t divisor, int64_t remainder,
199848b8605Smrg		      int64_t * msc, int64_t * sbc);
200848b8605Smrg
201848b8605Smrg    /**
202848b8605Smrg     * Get the number of vertical refreshes since some point in time before
203848b8605Smrg     * this function was first called (i.e., system start up).
204848b8605Smrg     */
205848b8605Smrg    int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
206848b8605Smrg			  int64_t *msc);
207848b8605Smrg};
208848b8605Smrg
209848b8605Smrg
210848b8605Smrg#define __DRI_TEX_OFFSET "DRI_TexOffset"
211848b8605Smrg#define __DRI_TEX_OFFSET_VERSION 1
212848b8605Smrgstruct __DRItexOffsetExtensionRec {
213848b8605Smrg    __DRIextension base;
214848b8605Smrg
215848b8605Smrg    /**
216848b8605Smrg     * Method to override base texture image with a driver specific 'offset'.
217848b8605Smrg     * The depth passed in allows e.g. to ignore the alpha channel of texture
218848b8605Smrg     * images where the non-alpha components don't occupy a whole texel.
219848b8605Smrg     *
220848b8605Smrg     * For GLX_EXT_texture_from_pixmap with AIGLX.
221848b8605Smrg     */
222848b8605Smrg    void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
223848b8605Smrg			 unsigned long long offset, GLint depth, GLuint pitch);
224848b8605Smrg};
225848b8605Smrg
226848b8605Smrg
227848b8605Smrg/* Valid values for format in the setTexBuffer2 function below.  These
228848b8605Smrg * values match the GLX tokens for compatibility reasons, but we
229848b8605Smrg * define them here since the DRI interface can't depend on GLX. */
230848b8605Smrg#define __DRI_TEXTURE_FORMAT_NONE        0x20D8
231848b8605Smrg#define __DRI_TEXTURE_FORMAT_RGB         0x20D9
232848b8605Smrg#define __DRI_TEXTURE_FORMAT_RGBA        0x20DA
233848b8605Smrg
234848b8605Smrg#define __DRI_TEX_BUFFER "DRI_TexBuffer"
235848b8605Smrg#define __DRI_TEX_BUFFER_VERSION 3
236848b8605Smrgstruct __DRItexBufferExtensionRec {
237848b8605Smrg    __DRIextension base;
238848b8605Smrg
239848b8605Smrg    /**
240848b8605Smrg     * Method to override base texture image with the contents of a
241848b8605Smrg     * __DRIdrawable.
242848b8605Smrg     *
243848b8605Smrg     * For GLX_EXT_texture_from_pixmap with AIGLX.  Deprecated in favor of
244848b8605Smrg     * setTexBuffer2 in version 2 of this interface
245848b8605Smrg     */
246848b8605Smrg    void (*setTexBuffer)(__DRIcontext *pDRICtx,
247848b8605Smrg			 GLint target,
248848b8605Smrg			 __DRIdrawable *pDraw);
249848b8605Smrg
250848b8605Smrg    /**
251848b8605Smrg     * Method to override base texture image with the contents of a
252848b8605Smrg     * __DRIdrawable, including the required texture format attribute.
253848b8605Smrg     *
254848b8605Smrg     * For GLX_EXT_texture_from_pixmap with AIGLX.
255848b8605Smrg     *
256848b8605Smrg     * \since 2
257848b8605Smrg     */
258848b8605Smrg    void (*setTexBuffer2)(__DRIcontext *pDRICtx,
259848b8605Smrg			  GLint target,
260848b8605Smrg			  GLint format,
261848b8605Smrg			  __DRIdrawable *pDraw);
262848b8605Smrg    /**
263848b8605Smrg     * Method to release texture buffer in case some special platform
264848b8605Smrg     * need this.
265848b8605Smrg     *
266848b8605Smrg     * For GLX_EXT_texture_from_pixmap with AIGLX.
267848b8605Smrg     *
268848b8605Smrg     * \since 3
269848b8605Smrg     */
270848b8605Smrg    void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
271848b8605Smrg			GLint target,
272848b8605Smrg			__DRIdrawable *pDraw);
273848b8605Smrg};
274848b8605Smrg
275848b8605Smrg/**
276848b8605Smrg * Used by drivers that implement DRI2
277848b8605Smrg */
278848b8605Smrg#define __DRI2_FLUSH "DRI2_Flush"
279848b8605Smrg#define __DRI2_FLUSH_VERSION 4
280848b8605Smrg
281848b8605Smrg#define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
282848b8605Smrg#define __DRI2_FLUSH_CONTEXT  (1 << 1) /* glFlush should be called */
283b8e80941Smrg#define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2)
284848b8605Smrg
285848b8605Smrgenum __DRI2throttleReason {
286848b8605Smrg   __DRI2_THROTTLE_SWAPBUFFER,
287848b8605Smrg   __DRI2_THROTTLE_COPYSUBBUFFER,
288848b8605Smrg   __DRI2_THROTTLE_FLUSHFRONT
289848b8605Smrg};
290848b8605Smrg
291848b8605Smrgstruct __DRI2flushExtensionRec {
292848b8605Smrg    __DRIextension base;
293848b8605Smrg    void (*flush)(__DRIdrawable *drawable);
294848b8605Smrg
295848b8605Smrg    /**
296848b8605Smrg     * Ask the driver to call getBuffers/getBuffersWithFormat before
297848b8605Smrg     * it starts rendering again.
298848b8605Smrg     *
299848b8605Smrg     * \param drawable the drawable to invalidate
300848b8605Smrg     *
301848b8605Smrg     * \since 3
302848b8605Smrg     */
303848b8605Smrg    void (*invalidate)(__DRIdrawable *drawable);
304848b8605Smrg
305848b8605Smrg    /**
306848b8605Smrg     * This function reduces the number of flushes in the driver by combining
307848b8605Smrg     * several operations into one call.
308848b8605Smrg     *
309848b8605Smrg     * It can:
310848b8605Smrg     * - throttle
311848b8605Smrg     * - flush a drawable
312848b8605Smrg     * - flush a context
313848b8605Smrg     *
314848b8605Smrg     * \param context           the context
315848b8605Smrg     * \param drawable          the drawable to flush
316848b8605Smrg     * \param flags             a combination of _DRI2_FLUSH_xxx flags
317848b8605Smrg     * \param throttle_reason   the reason for throttling, 0 = no throttling
318848b8605Smrg     *
319848b8605Smrg     * \since 4
320848b8605Smrg     */
321848b8605Smrg    void (*flush_with_flags)(__DRIcontext *ctx,
322848b8605Smrg                             __DRIdrawable *drawable,
323848b8605Smrg                             unsigned flags,
324848b8605Smrg                             enum __DRI2throttleReason throttle_reason);
325848b8605Smrg};
326848b8605Smrg
327848b8605Smrg
328848b8605Smrg/**
329848b8605Smrg * Extension that the driver uses to request
330848b8605Smrg * throttle callbacks.
331848b8605Smrg */
332848b8605Smrg
333848b8605Smrg#define __DRI2_THROTTLE "DRI2_Throttle"
334848b8605Smrg#define __DRI2_THROTTLE_VERSION 1
335848b8605Smrg
336848b8605Smrgstruct __DRI2throttleExtensionRec {
337848b8605Smrg   __DRIextension base;
338848b8605Smrg   void (*throttle)(__DRIcontext *ctx,
339848b8605Smrg		    __DRIdrawable *drawable,
340848b8605Smrg		    enum __DRI2throttleReason reason);
341848b8605Smrg};
342848b8605Smrg
343b8e80941Smrg/**
344b8e80941Smrg * Extension for EGL_ANDROID_blob_cache
345b8e80941Smrg */
346b8e80941Smrg
347b8e80941Smrg#define __DRI2_BLOB "DRI2_Blob"
348b8e80941Smrg#define __DRI2_BLOB_VERSION 1
349b8e80941Smrg
350b8e80941Smrgtypedef void
351b8e80941Smrg(*__DRIblobCacheSet) (const void *key, signed long keySize,
352b8e80941Smrg                      const void *value, signed long valueSize);
353b8e80941Smrg
354b8e80941Smrgtypedef signed long
355b8e80941Smrg(*__DRIblobCacheGet) (const void *key, signed long keySize,
356b8e80941Smrg                      void *value, signed long valueSize);
357b8e80941Smrg
358b8e80941Smrgstruct __DRI2blobExtensionRec {
359b8e80941Smrg   __DRIextension base;
360b8e80941Smrg
361b8e80941Smrg   /**
362b8e80941Smrg    * Set cache functions for setting and getting cache entries.
363b8e80941Smrg    */
364b8e80941Smrg   void (*set_cache_funcs) (__DRIscreen *screen,
365b8e80941Smrg                            __DRIblobCacheSet set, __DRIblobCacheGet get);
366b8e80941Smrg};
367b8e80941Smrg
368b8e80941Smrg/**
369b8e80941Smrg * Extension for fences / synchronization objects.
370b8e80941Smrg */
371b8e80941Smrg
372b8e80941Smrg#define __DRI2_FENCE "DRI2_Fence"
373b8e80941Smrg#define __DRI2_FENCE_VERSION 2
374b8e80941Smrg
375b8e80941Smrg#define __DRI2_FENCE_TIMEOUT_INFINITE     0xffffffffffffffffull
376b8e80941Smrg
377b8e80941Smrg#define __DRI2_FENCE_FLAG_FLUSH_COMMANDS  (1 << 0)
378b8e80941Smrg
379b8e80941Smrg/**
380b8e80941Smrg * \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities
381b8e80941Smrg */
382b8e80941Smrg/*@{*/
383b8e80941Smrg#define __DRI_FENCE_CAP_NATIVE_FD 1
384b8e80941Smrg/*@}*/
385b8e80941Smrg
386b8e80941Smrgstruct __DRI2fenceExtensionRec {
387b8e80941Smrg   __DRIextension base;
388b8e80941Smrg
389b8e80941Smrg   /**
390b8e80941Smrg    * Create and insert a fence into the command stream of the context.
391b8e80941Smrg    */
392b8e80941Smrg   void *(*create_fence)(__DRIcontext *ctx);
393b8e80941Smrg
394b8e80941Smrg   /**
395b8e80941Smrg    * Get a fence associated with the OpenCL event object.
396b8e80941Smrg    * This can be NULL, meaning that OpenCL interoperability is not supported.
397b8e80941Smrg    */
398b8e80941Smrg   void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event);
399b8e80941Smrg
400b8e80941Smrg   /**
401b8e80941Smrg    * Destroy a fence.
402b8e80941Smrg    */
403b8e80941Smrg   void (*destroy_fence)(__DRIscreen *screen, void *fence);
404b8e80941Smrg
405b8e80941Smrg   /**
406b8e80941Smrg    * This function waits and doesn't return until the fence is signalled
407b8e80941Smrg    * or the timeout expires. It returns true if the fence has been signaled.
408b8e80941Smrg    *
409b8e80941Smrg    * \param ctx     the context where commands are flushed
410b8e80941Smrg    * \param fence   the fence
411b8e80941Smrg    * \param flags   a combination of __DRI2_FENCE_FLAG_xxx flags
412b8e80941Smrg    * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE
413b8e80941Smrg    */
414b8e80941Smrg   GLboolean (*client_wait_sync)(__DRIcontext *ctx, void *fence,
415b8e80941Smrg                                 unsigned flags, uint64_t timeout);
416b8e80941Smrg
417b8e80941Smrg   /**
418b8e80941Smrg    * This function enqueues a wait command into the command stream of
419b8e80941Smrg    * the context and then returns. When the execution reaches the wait
420b8e80941Smrg    * command, no further execution will be done in the context until
421b8e80941Smrg    * the fence is signaled. This is a no-op if the device doesn't support
422b8e80941Smrg    * parallel execution of contexts.
423b8e80941Smrg    *
424b8e80941Smrg    * \param ctx     the context where the waiting is done
425b8e80941Smrg    * \param fence   the fence
426b8e80941Smrg    * \param flags   a combination of __DRI2_FENCE_FLAG_xxx flags that make
427b8e80941Smrg    *                sense with this function (right now there are none)
428b8e80941Smrg    */
429b8e80941Smrg   void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags);
430b8e80941Smrg
431b8e80941Smrg   /**
432b8e80941Smrg    * Query for general capabilities of the driver that concern fences.
433b8e80941Smrg    * Returns a bitmask of __DRI_FENCE_CAP_x
434b8e80941Smrg    *
435b8e80941Smrg    * \since 2
436b8e80941Smrg    */
437b8e80941Smrg   unsigned (*get_capabilities)(__DRIscreen *screen);
438b8e80941Smrg
439b8e80941Smrg   /**
440b8e80941Smrg    * Create an fd (file descriptor) associated fence.  If the fence fd
441b8e80941Smrg    * is -1, this behaves similarly to create_fence() except that when
442b8e80941Smrg    * rendering is flushed the driver creates a fence fd.  Otherwise,
443b8e80941Smrg    * the driver wraps an existing fence fd.
444b8e80941Smrg    *
445b8e80941Smrg    * This is used to implement the EGL_ANDROID_native_fence_sync extension.
446b8e80941Smrg    *
447b8e80941Smrg    * \since 2
448b8e80941Smrg    *
449b8e80941Smrg    * \param ctx     the context associated with the fence
450b8e80941Smrg    * \param fd      the fence fd or -1
451b8e80941Smrg    */
452b8e80941Smrg   void *(*create_fence_fd)(__DRIcontext *ctx, int fd);
453b8e80941Smrg
454b8e80941Smrg   /**
455b8e80941Smrg    * For fences created with create_fence_fd(), after rendering is flushed,
456b8e80941Smrg    * this retrieves the native fence fd.  Caller takes ownership of the
457b8e80941Smrg    * fd and will close() it when it is no longer needed.
458b8e80941Smrg    *
459b8e80941Smrg    * \since 2
460b8e80941Smrg    *
461b8e80941Smrg    * \param screen  the screen associated with the fence
462b8e80941Smrg    * \param fence   the fence
463b8e80941Smrg    */
464b8e80941Smrg   int (*get_fence_fd)(__DRIscreen *screen, void *fence);
465b8e80941Smrg};
466b8e80941Smrg
467b8e80941Smrg
468b8e80941Smrg/**
469b8e80941Smrg * Extension for API interop.
470b8e80941Smrg * See GL/mesa_glinterop.h.
471b8e80941Smrg */
472b8e80941Smrg
473b8e80941Smrg#define __DRI2_INTEROP "DRI2_Interop"
474b8e80941Smrg#define __DRI2_INTEROP_VERSION 1
475b8e80941Smrg
476b8e80941Smrgstruct mesa_glinterop_device_info;
477b8e80941Smrgstruct mesa_glinterop_export_in;
478b8e80941Smrgstruct mesa_glinterop_export_out;
479b8e80941Smrg
480b8e80941Smrgstruct __DRI2interopExtensionRec {
481b8e80941Smrg   __DRIextension base;
482b8e80941Smrg
483b8e80941Smrg   /** Same as MesaGLInterop*QueryDeviceInfo. */
484b8e80941Smrg   int (*query_device_info)(__DRIcontext *ctx,
485b8e80941Smrg                            struct mesa_glinterop_device_info *out);
486b8e80941Smrg
487b8e80941Smrg   /** Same as MesaGLInterop*ExportObject. */
488b8e80941Smrg   int (*export_object)(__DRIcontext *ctx,
489b8e80941Smrg                        struct mesa_glinterop_export_in *in,
490b8e80941Smrg                        struct mesa_glinterop_export_out *out);
491b8e80941Smrg};
492b8e80941Smrg
493848b8605Smrg/*@}*/
494848b8605Smrg
495848b8605Smrg/**
496848b8605Smrg * The following extensions describe loader features that the DRI
497848b8605Smrg * driver can make use of.  Some of these are mandatory, such as the
498848b8605Smrg * getDrawableInfo extension for DRI and the DRI Loader extensions for
499848b8605Smrg * DRI2, while others are optional, and if present allow the driver to
500848b8605Smrg * expose certain features.  The loader pass in a NULL terminated
501848b8605Smrg * array of these extensions to the driver in the createNewScreen
502848b8605Smrg * constructor.
503848b8605Smrg */
504848b8605Smrg
505848b8605Smrgtypedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
506848b8605Smrgtypedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
507848b8605Smrgtypedef struct __DRIdamageExtensionRec __DRIdamageExtension;
508848b8605Smrgtypedef struct __DRIloaderExtensionRec __DRIloaderExtension;
509848b8605Smrgtypedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
510848b8605Smrg
511848b8605Smrg
512848b8605Smrg/**
513848b8605Smrg * Callback to getDrawableInfo protocol
514848b8605Smrg */
515848b8605Smrg#define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
516848b8605Smrg#define __DRI_GET_DRAWABLE_INFO_VERSION 1
517848b8605Smrgstruct __DRIgetDrawableInfoExtensionRec {
518848b8605Smrg    __DRIextension base;
519848b8605Smrg
520848b8605Smrg    /**
521848b8605Smrg     * This function is used to get information about the position, size, and
522848b8605Smrg     * clip rects of a drawable.
523848b8605Smrg     */
524848b8605Smrg    GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
525848b8605Smrg	unsigned int * index, unsigned int * stamp,
526848b8605Smrg        int * x, int * y, int * width, int * height,
527848b8605Smrg        int * numClipRects, drm_clip_rect_t ** pClipRects,
528848b8605Smrg        int * backX, int * backY,
529848b8605Smrg	int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
530848b8605Smrg	void *loaderPrivate);
531848b8605Smrg};
532848b8605Smrg
533848b8605Smrg/**
534848b8605Smrg * Callback to get system time for media stream counter extensions.
535848b8605Smrg */
536848b8605Smrg#define __DRI_SYSTEM_TIME "DRI_SystemTime"
537848b8605Smrg#define __DRI_SYSTEM_TIME_VERSION 1
538848b8605Smrgstruct __DRIsystemTimeExtensionRec {
539848b8605Smrg    __DRIextension base;
540848b8605Smrg
541848b8605Smrg    /**
542848b8605Smrg     * Get the 64-bit unadjusted system time (UST).
543848b8605Smrg     */
544848b8605Smrg    int (*getUST)(int64_t * ust);
545848b8605Smrg
546848b8605Smrg    /**
547848b8605Smrg     * Get the media stream counter (MSC) rate.
548848b8605Smrg     *
549848b8605Smrg     * Matching the definition in GLX_OML_sync_control, this function returns
550848b8605Smrg     * the rate of the "media stream counter".  In practical terms, this is
551848b8605Smrg     * the frame refresh rate of the display.
552848b8605Smrg     */
553848b8605Smrg    GLboolean (*getMSCRate)(__DRIdrawable *draw,
554848b8605Smrg			    int32_t * numerator, int32_t * denominator,
555848b8605Smrg			    void *loaderPrivate);
556848b8605Smrg};
557848b8605Smrg
558848b8605Smrg/**
559848b8605Smrg * Damage reporting
560848b8605Smrg */
561848b8605Smrg#define __DRI_DAMAGE "DRI_Damage"
562848b8605Smrg#define __DRI_DAMAGE_VERSION 1
563848b8605Smrgstruct __DRIdamageExtensionRec {
564848b8605Smrg    __DRIextension base;
565848b8605Smrg
566848b8605Smrg    /**
567848b8605Smrg     * Reports areas of the given drawable which have been modified by the
568848b8605Smrg     * driver.
569848b8605Smrg     *
570848b8605Smrg     * \param drawable which the drawing was done to.
571848b8605Smrg     * \param rects rectangles affected, with the drawable origin as the
572848b8605Smrg     *	      origin.
573848b8605Smrg     * \param x X offset of the drawable within the screen (used in the
574848b8605Smrg     *	      front_buffer case)
575848b8605Smrg     * \param y Y offset of the drawable within the screen.
576848b8605Smrg     * \param front_buffer boolean flag for whether the drawing to the
577848b8605Smrg     * 	      drawable was actually done directly to the front buffer (instead
578848b8605Smrg     *	      of backing storage, for example)
579848b8605Smrg     * \param loaderPrivate the data passed in at createNewDrawable time
580848b8605Smrg     */
581848b8605Smrg    void (*reportDamage)(__DRIdrawable *draw,
582848b8605Smrg			 int x, int y,
583848b8605Smrg			 drm_clip_rect_t *rects, int num_rects,
584848b8605Smrg			 GLboolean front_buffer,
585848b8605Smrg			 void *loaderPrivate);
586848b8605Smrg};
587848b8605Smrg
588848b8605Smrg#define __DRI_SWRAST_IMAGE_OP_DRAW	1
589848b8605Smrg#define __DRI_SWRAST_IMAGE_OP_CLEAR	2
590848b8605Smrg#define __DRI_SWRAST_IMAGE_OP_SWAP	3
591848b8605Smrg
592848b8605Smrg/**
593848b8605Smrg * SWRast Loader extension.
594848b8605Smrg */
595848b8605Smrg#define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
596b8e80941Smrg#define __DRI_SWRAST_LOADER_VERSION 5
597848b8605Smrgstruct __DRIswrastLoaderExtensionRec {
598848b8605Smrg    __DRIextension base;
599848b8605Smrg
600848b8605Smrg    /*
601848b8605Smrg     * Drawable position and size
602848b8605Smrg     */
603848b8605Smrg    void (*getDrawableInfo)(__DRIdrawable *drawable,
604848b8605Smrg			    int *x, int *y, int *width, int *height,
605848b8605Smrg			    void *loaderPrivate);
606848b8605Smrg
607848b8605Smrg    /**
608848b8605Smrg     * Put image to drawable
609848b8605Smrg     */
610848b8605Smrg    void (*putImage)(__DRIdrawable *drawable, int op,
611848b8605Smrg		     int x, int y, int width, int height,
612848b8605Smrg		     char *data, void *loaderPrivate);
613848b8605Smrg
614848b8605Smrg    /**
615848b8605Smrg     * Get image from readable
616848b8605Smrg     */
617848b8605Smrg    void (*getImage)(__DRIdrawable *readable,
618848b8605Smrg		     int x, int y, int width, int height,
619848b8605Smrg		     char *data, void *loaderPrivate);
620848b8605Smrg
621848b8605Smrg    /**
622848b8605Smrg     * Put image to drawable
623848b8605Smrg     *
624848b8605Smrg     * \since 2
625848b8605Smrg     */
626848b8605Smrg    void (*putImage2)(__DRIdrawable *drawable, int op,
627848b8605Smrg                      int x, int y, int width, int height, int stride,
628848b8605Smrg                      char *data, void *loaderPrivate);
629b8e80941Smrg
630b8e80941Smrg   /**
631b8e80941Smrg     * Put image to drawable
632b8e80941Smrg     *
633b8e80941Smrg     * \since 3
634b8e80941Smrg     */
635b8e80941Smrg   void (*getImage2)(__DRIdrawable *readable,
636b8e80941Smrg		     int x, int y, int width, int height, int stride,
637b8e80941Smrg		     char *data, void *loaderPrivate);
638b8e80941Smrg
639b8e80941Smrg    /**
640b8e80941Smrg     * Put shm image to drawable
641b8e80941Smrg     *
642b8e80941Smrg     * \since 4
643b8e80941Smrg     */
644b8e80941Smrg    void (*putImageShm)(__DRIdrawable *drawable, int op,
645b8e80941Smrg                        int x, int y, int width, int height, int stride,
646b8e80941Smrg                        int shmid, char *shmaddr, unsigned offset,
647b8e80941Smrg                        void *loaderPrivate);
648b8e80941Smrg    /**
649b8e80941Smrg     * Get shm image from readable
650b8e80941Smrg     *
651b8e80941Smrg     * \since 4
652b8e80941Smrg     */
653b8e80941Smrg    void (*getImageShm)(__DRIdrawable *readable,
654b8e80941Smrg                        int x, int y, int width, int height,
655b8e80941Smrg                        int shmid, void *loaderPrivate);
656b8e80941Smrg
657b8e80941Smrg   /**
658b8e80941Smrg     * Put shm image to drawable (v2)
659b8e80941Smrg     *
660b8e80941Smrg     * The original version fixes srcx/y to 0, and expected
661b8e80941Smrg     * the offset to be adjusted. This version allows src x,y
662b8e80941Smrg     * to not be included in the offset. This is needed to
663b8e80941Smrg     * avoid certain overflow checks in the X server, that
664b8e80941Smrg     * result in lost rendering.
665b8e80941Smrg     *
666b8e80941Smrg     * \since 5
667b8e80941Smrg     */
668b8e80941Smrg    void (*putImageShm2)(__DRIdrawable *drawable, int op,
669b8e80941Smrg                         int x, int y,
670b8e80941Smrg                         int width, int height, int stride,
671b8e80941Smrg                         int shmid, char *shmaddr, unsigned offset,
672b8e80941Smrg                         void *loaderPrivate);
673848b8605Smrg};
674848b8605Smrg
675848b8605Smrg/**
676848b8605Smrg * Invalidate loader extension.  The presence of this extension
677848b8605Smrg * indicates to the DRI driver that the loader will call invalidate in
678848b8605Smrg * the __DRI2_FLUSH extension, whenever the needs to query for new
679848b8605Smrg * buffers.  This means that the DRI driver can drop the polling in
680848b8605Smrg * glViewport().
681848b8605Smrg *
682848b8605Smrg * The extension doesn't provide any functionality, it's only use to
683848b8605Smrg * indicate to the driver that it can use the new semantics.  A DRI
684848b8605Smrg * driver can use this to switch between the different semantics or
685848b8605Smrg * just refuse to initialize if this extension isn't present.
686848b8605Smrg */
687848b8605Smrg#define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
688848b8605Smrg#define __DRI_USE_INVALIDATE_VERSION 1
689848b8605Smrg
690848b8605Smrgtypedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
691848b8605Smrgstruct __DRIuseInvalidateExtensionRec {
692848b8605Smrg   __DRIextension base;
693848b8605Smrg};
694848b8605Smrg
695848b8605Smrg/**
696848b8605Smrg * The remaining extensions describe driver extensions, immediately
697848b8605Smrg * available interfaces provided by the driver.  To start using the
698848b8605Smrg * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
699848b8605Smrg * the extension you need in the array.
700848b8605Smrg */
701848b8605Smrg#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
702848b8605Smrg
703848b8605Smrg/**
704848b8605Smrg * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
705848b8605Smrg * suffixed by "_drivername", allowing multiple drivers to be built into one
706848b8605Smrg * library, and also giving the driver the chance to return a variable driver
707848b8605Smrg * extensions struct depending on the driver name being loaded or any other
708848b8605Smrg * system state.
709848b8605Smrg *
710848b8605Smrg * The function prototype is:
711848b8605Smrg *
712848b8605Smrg * const __DRIextension **__driDriverGetExtensions_drivername(void);
713848b8605Smrg */
714848b8605Smrg#define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
715848b8605Smrg
716848b8605Smrg/**
717848b8605Smrg * Tokens for __DRIconfig attribs.  A number of attributes defined by
718848b8605Smrg * GLX or EGL standards are not in the table, as they must be provided
719848b8605Smrg * by the loader.  For example, FBConfig ID or visual ID, drawable type.
720848b8605Smrg */
721848b8605Smrg
722848b8605Smrg#define __DRI_ATTRIB_BUFFER_SIZE		 1
723848b8605Smrg#define __DRI_ATTRIB_LEVEL			 2
724848b8605Smrg#define __DRI_ATTRIB_RED_SIZE			 3
725848b8605Smrg#define __DRI_ATTRIB_GREEN_SIZE			 4
726848b8605Smrg#define __DRI_ATTRIB_BLUE_SIZE			 5
727848b8605Smrg#define __DRI_ATTRIB_LUMINANCE_SIZE		 6
728848b8605Smrg#define __DRI_ATTRIB_ALPHA_SIZE			 7
729848b8605Smrg#define __DRI_ATTRIB_ALPHA_MASK_SIZE		 8
730848b8605Smrg#define __DRI_ATTRIB_DEPTH_SIZE			 9
731848b8605Smrg#define __DRI_ATTRIB_STENCIL_SIZE		10
732848b8605Smrg#define __DRI_ATTRIB_ACCUM_RED_SIZE		11
733848b8605Smrg#define __DRI_ATTRIB_ACCUM_GREEN_SIZE		12
734848b8605Smrg#define __DRI_ATTRIB_ACCUM_BLUE_SIZE		13
735848b8605Smrg#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE		14
736848b8605Smrg#define __DRI_ATTRIB_SAMPLE_BUFFERS		15
737848b8605Smrg#define __DRI_ATTRIB_SAMPLES			16
738848b8605Smrg#define __DRI_ATTRIB_RENDER_TYPE		17
739848b8605Smrg#define __DRI_ATTRIB_CONFIG_CAVEAT		18
740848b8605Smrg#define __DRI_ATTRIB_CONFORMANT			19
741848b8605Smrg#define __DRI_ATTRIB_DOUBLE_BUFFER		20
742848b8605Smrg#define __DRI_ATTRIB_STEREO			21
743848b8605Smrg#define __DRI_ATTRIB_AUX_BUFFERS		22
744848b8605Smrg#define __DRI_ATTRIB_TRANSPARENT_TYPE		23
745848b8605Smrg#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE	24
746848b8605Smrg#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE	25
747848b8605Smrg#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE	26
748848b8605Smrg#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE	27
749848b8605Smrg#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE	28
750848b8605Smrg#define __DRI_ATTRIB_FLOAT_MODE			29
751848b8605Smrg#define __DRI_ATTRIB_RED_MASK			30
752848b8605Smrg#define __DRI_ATTRIB_GREEN_MASK			31
753848b8605Smrg#define __DRI_ATTRIB_BLUE_MASK			32
754848b8605Smrg#define __DRI_ATTRIB_ALPHA_MASK			33
755848b8605Smrg#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH		34
756848b8605Smrg#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT		35
757848b8605Smrg#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS		36
758848b8605Smrg#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH	37
759848b8605Smrg#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT	38
760848b8605Smrg#define __DRI_ATTRIB_VISUAL_SELECT_GROUP	39
761848b8605Smrg#define __DRI_ATTRIB_SWAP_METHOD		40
762848b8605Smrg#define __DRI_ATTRIB_MAX_SWAP_INTERVAL		41
763848b8605Smrg#define __DRI_ATTRIB_MIN_SWAP_INTERVAL		42
764848b8605Smrg#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB	43
765848b8605Smrg#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA	44
766848b8605Smrg#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE	45
767848b8605Smrg#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS	46
768848b8605Smrg#define __DRI_ATTRIB_YINVERTED			47
769848b8605Smrg#define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE	48
770b8e80941Smrg#define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER	49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */
771b8e80941Smrg#define __DRI_ATTRIB_MAX			50
772848b8605Smrg
773848b8605Smrg/* __DRI_ATTRIB_RENDER_TYPE */
774848b8605Smrg#define __DRI_ATTRIB_RGBA_BIT			0x01
775848b8605Smrg#define __DRI_ATTRIB_COLOR_INDEX_BIT		0x02
776848b8605Smrg#define __DRI_ATTRIB_LUMINANCE_BIT		0x04
777848b8605Smrg#define __DRI_ATTRIB_FLOAT_BIT			0x08
778848b8605Smrg#define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT		0x10
779848b8605Smrg
780848b8605Smrg/* __DRI_ATTRIB_CONFIG_CAVEAT */
781848b8605Smrg#define __DRI_ATTRIB_SLOW_BIT			0x01
782848b8605Smrg#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG	0x02
783848b8605Smrg
784848b8605Smrg/* __DRI_ATTRIB_TRANSPARENT_TYPE */
785848b8605Smrg#define __DRI_ATTRIB_TRANSPARENT_RGB		0x00
786848b8605Smrg#define __DRI_ATTRIB_TRANSPARENT_INDEX		0x01
787848b8605Smrg
788848b8605Smrg/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS	 */
789848b8605Smrg#define __DRI_ATTRIB_TEXTURE_1D_BIT		0x01
790848b8605Smrg#define __DRI_ATTRIB_TEXTURE_2D_BIT		0x02
791848b8605Smrg#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT	0x04
792848b8605Smrg
793b8e80941Smrg/* __DRI_ATTRIB_SWAP_METHOD */
794b8e80941Smrg/* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define
795b8e80941Smrg * the same tokens as GLX. This is because old and current X servers will
796b8e80941Smrg * transmit the driconf value grabbed from the AIGLX driver untranslated as
797b8e80941Smrg * the GLX fbconfig value. __DRI_ATTRIB_SWAP_NONE is only used by dri drivers
798b8e80941Smrg * to signal to the dri core that the driconfig is single-buffer.
799b8e80941Smrg */
800b8e80941Smrg#define __DRI_ATTRIB_SWAP_NONE                  0x0000
801b8e80941Smrg#define __DRI_ATTRIB_SWAP_EXCHANGE              0x8061
802b8e80941Smrg#define __DRI_ATTRIB_SWAP_COPY                  0x8062
803b8e80941Smrg#define __DRI_ATTRIB_SWAP_UNDEFINED             0x8063
804b8e80941Smrg
805848b8605Smrg/**
806848b8605Smrg * This extension defines the core DRI functionality.
807b8e80941Smrg *
808b8e80941Smrg * Version >= 2 indicates that getConfigAttrib with __DRI_ATTRIB_SWAP_METHOD
809b8e80941Smrg * returns a reliable value.
810848b8605Smrg */
811848b8605Smrg#define __DRI_CORE "DRI_Core"
812b8e80941Smrg#define __DRI_CORE_VERSION 2
813848b8605Smrg
814848b8605Smrgstruct __DRIcoreExtensionRec {
815848b8605Smrg    __DRIextension base;
816848b8605Smrg
817848b8605Smrg    __DRIscreen *(*createNewScreen)(int screen, int fd,
818848b8605Smrg				    unsigned int sarea_handle,
819848b8605Smrg				    const __DRIextension **extensions,
820848b8605Smrg				    const __DRIconfig ***driverConfigs,
821848b8605Smrg				    void *loaderPrivate);
822848b8605Smrg
823848b8605Smrg    void (*destroyScreen)(__DRIscreen *screen);
824848b8605Smrg
825848b8605Smrg    const __DRIextension **(*getExtensions)(__DRIscreen *screen);
826848b8605Smrg
827848b8605Smrg    int (*getConfigAttrib)(const __DRIconfig *config,
828848b8605Smrg			   unsigned int attrib,
829848b8605Smrg			   unsigned int *value);
830848b8605Smrg
831848b8605Smrg    int (*indexConfigAttrib)(const __DRIconfig *config, int index,
832848b8605Smrg			     unsigned int *attrib, unsigned int *value);
833848b8605Smrg
834848b8605Smrg    __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
835848b8605Smrg					const __DRIconfig *config,
836848b8605Smrg					unsigned int drawable_id,
837848b8605Smrg					unsigned int head,
838848b8605Smrg					void *loaderPrivate);
839848b8605Smrg
840848b8605Smrg    void (*destroyDrawable)(__DRIdrawable *drawable);
841848b8605Smrg
842848b8605Smrg    void (*swapBuffers)(__DRIdrawable *drawable);
843848b8605Smrg
844848b8605Smrg    __DRIcontext *(*createNewContext)(__DRIscreen *screen,
845848b8605Smrg				      const __DRIconfig *config,
846848b8605Smrg				      __DRIcontext *shared,
847848b8605Smrg				      void *loaderPrivate);
848848b8605Smrg
849848b8605Smrg    int (*copyContext)(__DRIcontext *dest,
850848b8605Smrg		       __DRIcontext *src,
851848b8605Smrg		       unsigned long mask);
852848b8605Smrg
853848b8605Smrg    void (*destroyContext)(__DRIcontext *context);
854848b8605Smrg
855848b8605Smrg    int (*bindContext)(__DRIcontext *ctx,
856848b8605Smrg		       __DRIdrawable *pdraw,
857848b8605Smrg		       __DRIdrawable *pread);
858848b8605Smrg
859848b8605Smrg    int (*unbindContext)(__DRIcontext *ctx);
860848b8605Smrg};
861848b8605Smrg
862848b8605Smrg/**
863848b8605Smrg * Stored version of some component (i.e., server-side DRI module, kernel-side
864848b8605Smrg * DRM, etc.).
865848b8605Smrg *
866848b8605Smrg * \todo
867848b8605Smrg * There are several data structures that explicitly store a major version,
868848b8605Smrg * minor version, and patch level.  These structures should be modified to
869848b8605Smrg * have a \c __DRIversionRec instead.
870848b8605Smrg */
871848b8605Smrgstruct __DRIversionRec {
872848b8605Smrg    int    major;        /**< Major version number. */
873848b8605Smrg    int    minor;        /**< Minor version number. */
874848b8605Smrg    int    patch;        /**< Patch-level. */
875848b8605Smrg};
876848b8605Smrg
877848b8605Smrg/**
878848b8605Smrg * Framebuffer information record.  Used by libGL to communicate information
879848b8605Smrg * about the framebuffer to the driver's \c __driCreateNewScreen function.
880848b8605Smrg *
881848b8605Smrg * In XFree86, most of this information is derrived from data returned by
882848b8605Smrg * calling \c XF86DRIGetDeviceInfo.
883848b8605Smrg *
884848b8605Smrg * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
885848b8605Smrg *     __driUtilCreateNewScreen CallCreateNewScreen
886848b8605Smrg *
887848b8605Smrg * \bug This structure could be better named.
888848b8605Smrg */
889848b8605Smrgstruct __DRIframebufferRec {
890848b8605Smrg    unsigned char *base;    /**< Framebuffer base address in the CPU's
891848b8605Smrg			     * address space.  This value is calculated by
892848b8605Smrg			     * calling \c drmMap on the framebuffer handle
893848b8605Smrg			     * returned by \c XF86DRIGetDeviceInfo (or a
894848b8605Smrg			     * similar function).
895848b8605Smrg			     */
896848b8605Smrg    int size;               /**< Framebuffer size, in bytes. */
897848b8605Smrg    int stride;             /**< Number of bytes from one line to the next. */
898848b8605Smrg    int width;              /**< Pixel width of the framebuffer. */
899848b8605Smrg    int height;             /**< Pixel height of the framebuffer. */
900848b8605Smrg    int dev_priv_size;      /**< Size of the driver's dev-priv structure. */
901848b8605Smrg    void *dev_priv;         /**< Pointer to the driver's dev-priv structure. */
902848b8605Smrg};
903848b8605Smrg
904848b8605Smrg
905848b8605Smrg/**
906848b8605Smrg * This extension provides alternative screen, drawable and context
907848b8605Smrg * constructors for legacy DRI functionality.  This is used in
908848b8605Smrg * conjunction with the core extension.
909848b8605Smrg */
910848b8605Smrg#define __DRI_LEGACY "DRI_Legacy"
911848b8605Smrg#define __DRI_LEGACY_VERSION 1
912848b8605Smrg
913848b8605Smrgstruct __DRIlegacyExtensionRec {
914848b8605Smrg    __DRIextension base;
915848b8605Smrg
916848b8605Smrg    __DRIscreen *(*createNewScreen)(int screen,
917848b8605Smrg				    const __DRIversion *ddx_version,
918848b8605Smrg				    const __DRIversion *dri_version,
919848b8605Smrg				    const __DRIversion *drm_version,
920848b8605Smrg				    const __DRIframebuffer *frame_buffer,
921848b8605Smrg				    void *pSAREA, int fd,
922848b8605Smrg				    const __DRIextension **extensions,
923848b8605Smrg				    const __DRIconfig ***driver_configs,
924848b8605Smrg				    void *loaderPrivate);
925848b8605Smrg
926848b8605Smrg    __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
927848b8605Smrg					const __DRIconfig *config,
928848b8605Smrg					drm_drawable_t hwDrawable,
929848b8605Smrg					int renderType, const int *attrs,
930848b8605Smrg					void *loaderPrivate);
931848b8605Smrg
932848b8605Smrg    __DRIcontext *(*createNewContext)(__DRIscreen *screen,
933848b8605Smrg				      const __DRIconfig *config,
934848b8605Smrg				      int render_type,
935848b8605Smrg				      __DRIcontext *shared,
936848b8605Smrg				      drm_context_t hwContext,
937848b8605Smrg				      void *loaderPrivate);
938848b8605Smrg};
939848b8605Smrg
940848b8605Smrg/**
941848b8605Smrg * This extension provides alternative screen, drawable and context
942848b8605Smrg * constructors for swrast DRI functionality.  This is used in
943848b8605Smrg * conjunction with the core extension.
944848b8605Smrg */
945848b8605Smrg#define __DRI_SWRAST "DRI_SWRast"
946848b8605Smrg#define __DRI_SWRAST_VERSION 4
947848b8605Smrg
948848b8605Smrgstruct __DRIswrastExtensionRec {
949848b8605Smrg    __DRIextension base;
950848b8605Smrg
951848b8605Smrg    __DRIscreen *(*createNewScreen)(int screen,
952848b8605Smrg				    const __DRIextension **extensions,
953848b8605Smrg				    const __DRIconfig ***driver_configs,
954848b8605Smrg				    void *loaderPrivate);
955848b8605Smrg
956848b8605Smrg    __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
957848b8605Smrg					const __DRIconfig *config,
958848b8605Smrg					void *loaderPrivate);
959848b8605Smrg
960848b8605Smrg   /* Since version 2 */
961848b8605Smrg   __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
962848b8605Smrg                                           int api,
963848b8605Smrg                                           const __DRIconfig *config,
964848b8605Smrg                                           __DRIcontext *shared,
965848b8605Smrg                                           void *data);
966848b8605Smrg
967848b8605Smrg   /**
968848b8605Smrg    * Create a context for a particular API with a set of attributes
969848b8605Smrg    *
970848b8605Smrg    * \since version 3
971848b8605Smrg    *
972848b8605Smrg    * \sa __DRIdri2ExtensionRec::createContextAttribs
973848b8605Smrg    */
974848b8605Smrg   __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
975848b8605Smrg					 int api,
976848b8605Smrg					 const __DRIconfig *config,
977848b8605Smrg					 __DRIcontext *shared,
978848b8605Smrg					 unsigned num_attribs,
979848b8605Smrg					 const uint32_t *attribs,
980848b8605Smrg					 unsigned *error,
981848b8605Smrg					 void *loaderPrivate);
982848b8605Smrg
983848b8605Smrg   /**
984848b8605Smrg    * createNewScreen() with the driver extensions passed in.
985848b8605Smrg    *
986848b8605Smrg    * \since version 4
987848b8605Smrg    */
988848b8605Smrg   __DRIscreen *(*createNewScreen2)(int screen,
989848b8605Smrg                                    const __DRIextension **loader_extensions,
990848b8605Smrg                                    const __DRIextension **driver_extensions,
991848b8605Smrg                                    const __DRIconfig ***driver_configs,
992848b8605Smrg                                    void *loaderPrivate);
993848b8605Smrg
994848b8605Smrg};
995848b8605Smrg
996848b8605Smrg/** Common DRI function definitions, shared among DRI2 and Image extensions
997848b8605Smrg */
998848b8605Smrg
999848b8605Smrgtypedef __DRIscreen *
1000848b8605Smrg(*__DRIcreateNewScreen2Func)(int screen, int fd,
1001848b8605Smrg                             const __DRIextension **extensions,
1002848b8605Smrg                             const __DRIextension **driver_extensions,
1003848b8605Smrg                             const __DRIconfig ***driver_configs,
1004848b8605Smrg                             void *loaderPrivate);
1005848b8605Smrg
1006848b8605Smrgtypedef __DRIdrawable *
1007848b8605Smrg(*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
1008848b8605Smrg                              const __DRIconfig *config,
1009848b8605Smrg                              void *loaderPrivate);
1010848b8605Smrg
1011848b8605Smrgtypedef __DRIcontext *
1012848b8605Smrg(*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
1013848b8605Smrg                                 int api,
1014848b8605Smrg                                 const __DRIconfig *config,
1015848b8605Smrg                                 __DRIcontext *shared,
1016848b8605Smrg                                 unsigned num_attribs,
1017848b8605Smrg                                 const uint32_t *attribs,
1018848b8605Smrg                                 unsigned *error,
1019848b8605Smrg                                 void *loaderPrivate);
1020848b8605Smrg
1021848b8605Smrgtypedef unsigned int
1022848b8605Smrg(*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
1023848b8605Smrg
1024848b8605Smrg/**
1025848b8605Smrg * DRI2 Loader extension.
1026848b8605Smrg */
1027848b8605Smrg#define __DRI_BUFFER_FRONT_LEFT		0
1028848b8605Smrg#define __DRI_BUFFER_BACK_LEFT		1
1029848b8605Smrg#define __DRI_BUFFER_FRONT_RIGHT	2
1030848b8605Smrg#define __DRI_BUFFER_BACK_RIGHT		3
1031848b8605Smrg#define __DRI_BUFFER_DEPTH		4
1032848b8605Smrg#define __DRI_BUFFER_STENCIL		5
1033848b8605Smrg#define __DRI_BUFFER_ACCUM		6
1034848b8605Smrg#define __DRI_BUFFER_FAKE_FRONT_LEFT	7
1035848b8605Smrg#define __DRI_BUFFER_FAKE_FRONT_RIGHT	8
1036848b8605Smrg#define __DRI_BUFFER_DEPTH_STENCIL	9  /**< Only available with DRI2 1.1 */
1037848b8605Smrg#define __DRI_BUFFER_HIZ		10
1038848b8605Smrg
1039848b8605Smrg/* Inofficial and for internal use. Increase when adding a new buffer token. */
1040848b8605Smrg#define __DRI_BUFFER_COUNT		11
1041848b8605Smrg
1042848b8605Smrgstruct __DRIbufferRec {
1043848b8605Smrg    unsigned int attachment;
1044848b8605Smrg    unsigned int name;
1045848b8605Smrg    unsigned int pitch;
1046848b8605Smrg    unsigned int cpp;
1047848b8605Smrg    unsigned int flags;
1048848b8605Smrg};
1049848b8605Smrg
1050848b8605Smrg#define __DRI_DRI2_LOADER "DRI_DRI2Loader"
1051b8e80941Smrg#define __DRI_DRI2_LOADER_VERSION 4
1052b8e80941Smrg
1053b8e80941Smrgenum dri_loader_cap {
1054b8e80941Smrg   /* Whether the loader handles RGBA channel ordering correctly. If not,
1055b8e80941Smrg    * only BGRA ordering can be exposed.
1056b8e80941Smrg    */
1057b8e80941Smrg   DRI_LOADER_CAP_RGBA_ORDERING,
1058b8e80941Smrg};
1059b8e80941Smrg
1060848b8605Smrgstruct __DRIdri2LoaderExtensionRec {
1061848b8605Smrg    __DRIextension base;
1062848b8605Smrg
1063848b8605Smrg    __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
1064848b8605Smrg			       int *width, int *height,
1065848b8605Smrg			       unsigned int *attachments, int count,
1066848b8605Smrg			       int *out_count, void *loaderPrivate);
1067848b8605Smrg
1068848b8605Smrg    /**
1069848b8605Smrg     * Flush pending front-buffer rendering
1070848b8605Smrg     *
1071848b8605Smrg     * Any rendering that has been performed to the
1072848b8605Smrg     * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
1073848b8605Smrg     * \c __DRI_BUFFER_FRONT_LEFT.
1074848b8605Smrg     *
1075848b8605Smrg     * \param driDrawable    Drawable whose front-buffer is to be flushed
1076848b8605Smrg     * \param loaderPrivate  Loader's private data that was previously passed
1077848b8605Smrg     *                       into __DRIdri2ExtensionRec::createNewDrawable
1078848b8605Smrg     *
1079848b8605Smrg     * \since 2
1080848b8605Smrg     */
1081848b8605Smrg    void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
1082848b8605Smrg
1083848b8605Smrg
1084848b8605Smrg    /**
1085848b8605Smrg     * Get list of buffers from the server
1086848b8605Smrg     *
1087848b8605Smrg     * Gets a list of buffer for the specified set of attachments.  Unlike
1088848b8605Smrg     * \c ::getBuffers, this function takes a list of attachments paired with
1089848b8605Smrg     * opaque \c unsigned \c int value describing the format of the buffer.
1090848b8605Smrg     * It is the responsibility of the caller to know what the service that
1091848b8605Smrg     * allocates the buffers will expect to receive for the format.
1092848b8605Smrg     *
1093848b8605Smrg     * \param driDrawable    Drawable whose buffers are being queried.
1094848b8605Smrg     * \param width          Output where the width of the buffers is stored.
1095848b8605Smrg     * \param height         Output where the height of the buffers is stored.
1096848b8605Smrg     * \param attachments    List of pairs of attachment ID and opaque format
1097848b8605Smrg     *                       requested for the drawable.
1098848b8605Smrg     * \param count          Number of attachment / format pairs stored in
1099848b8605Smrg     *                       \c attachments.
1100848b8605Smrg     * \param loaderPrivate  Loader's private data that was previously passed
1101848b8605Smrg     *                       into __DRIdri2ExtensionRec::createNewDrawable.
1102848b8605Smrg     *
1103848b8605Smrg     * \since 3
1104848b8605Smrg     */
1105848b8605Smrg    __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
1106848b8605Smrg					 int *width, int *height,
1107848b8605Smrg					 unsigned int *attachments, int count,
1108848b8605Smrg					 int *out_count, void *loaderPrivate);
1109b8e80941Smrg
1110b8e80941Smrg    /**
1111b8e80941Smrg     * Return a loader capability value. If the loader doesn't know the enum,
1112b8e80941Smrg     * it will return 0.
1113b8e80941Smrg     *
1114b8e80941Smrg     * \param loaderPrivate The last parameter of createNewScreen or
1115b8e80941Smrg     *                      createNewScreen2.
1116b8e80941Smrg     * \param cap           See the enum.
1117b8e80941Smrg     *
1118b8e80941Smrg     * \since 4
1119b8e80941Smrg     */
1120b8e80941Smrg    unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
1121848b8605Smrg};
1122848b8605Smrg
1123848b8605Smrg/**
1124848b8605Smrg * This extension provides alternative screen, drawable and context
1125848b8605Smrg * constructors for DRI2.
1126848b8605Smrg */
1127848b8605Smrg#define __DRI_DRI2 "DRI_DRI2"
1128848b8605Smrg#define __DRI_DRI2_VERSION 4
1129848b8605Smrg
1130848b8605Smrg#define __DRI_API_OPENGL	0	/**< OpenGL compatibility profile */
1131848b8605Smrg#define __DRI_API_GLES		1	/**< OpenGL ES 1.x */
1132848b8605Smrg#define __DRI_API_GLES2		2	/**< OpenGL ES 2.x */
1133848b8605Smrg#define __DRI_API_OPENGL_CORE	3	/**< OpenGL 3.2+ core profile */
1134848b8605Smrg#define __DRI_API_GLES3		4	/**< OpenGL ES 3.x */
1135848b8605Smrg
1136848b8605Smrg#define __DRI_CTX_ATTRIB_MAJOR_VERSION		0
1137848b8605Smrg#define __DRI_CTX_ATTRIB_MINOR_VERSION		1
1138848b8605Smrg#define __DRI_CTX_ATTRIB_FLAGS			2
1139848b8605Smrg
1140848b8605Smrg/**
1141848b8605Smrg * \requires __DRI2_ROBUSTNESS.
1142848b8605Smrg */
1143848b8605Smrg#define __DRI_CTX_ATTRIB_RESET_STRATEGY		3
1144848b8605Smrg
1145848b8605Smrg#define __DRI_CTX_FLAG_DEBUG			0x00000001
1146848b8605Smrg#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE	0x00000002
1147848b8605Smrg
1148848b8605Smrg/**
1149848b8605Smrg * \requires __DRI2_ROBUSTNESS.
1150848b8605Smrg */
1151848b8605Smrg#define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS	0x00000004
1152848b8605Smrg
1153b8e80941Smrg/**
1154b8e80941Smrg * \requires __DRI2_NO_ERROR.
1155b8e80941Smrg *
1156b8e80941Smrg */
1157b8e80941Smrg#define __DRI_CTX_FLAG_NO_ERROR			0x00000008
1158b8e80941Smrg
1159848b8605Smrg/**
1160848b8605Smrg * \name Context reset strategies.
1161848b8605Smrg */
1162848b8605Smrg/*@{*/
1163848b8605Smrg#define __DRI_CTX_RESET_NO_NOTIFICATION		0
1164848b8605Smrg#define __DRI_CTX_RESET_LOSE_CONTEXT		1
1165848b8605Smrg/*@}*/
1166848b8605Smrg
1167b8e80941Smrg#define __DRI_CTX_ATTRIB_PRIORITY		4
1168b8e80941Smrg
1169b8e80941Smrg#define __DRI_CTX_PRIORITY_LOW			0
1170b8e80941Smrg#define __DRI_CTX_PRIORITY_MEDIUM		1
1171b8e80941Smrg#define __DRI_CTX_PRIORITY_HIGH			2
1172b8e80941Smrg
1173b8e80941Smrg/**
1174b8e80941Smrg * \name Context release behaviors.
1175b8e80941Smrg */
1176b8e80941Smrg/*@{*/
1177b8e80941Smrg#define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR	5
1178b8e80941Smrg
1179b8e80941Smrg#define __DRI_CTX_RELEASE_BEHAVIOR_NONE         0
1180b8e80941Smrg#define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH        1
1181b8e80941Smrg/*@}*/
1182b8e80941Smrg
1183848b8605Smrg/**
1184848b8605Smrg * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
1185848b8605Smrg */
1186848b8605Smrg/*@{*/
1187848b8605Smrg/** Success! */
1188848b8605Smrg#define __DRI_CTX_ERROR_SUCCESS			0
1189848b8605Smrg
1190848b8605Smrg/** Memory allocation failure */
1191848b8605Smrg#define __DRI_CTX_ERROR_NO_MEMORY		1
1192848b8605Smrg
1193848b8605Smrg/** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
1194848b8605Smrg#define __DRI_CTX_ERROR_BAD_API			2
1195848b8605Smrg
1196848b8605Smrg/** Client requested an API version that the driver can't do. */
1197848b8605Smrg#define __DRI_CTX_ERROR_BAD_VERSION		3
1198848b8605Smrg
1199848b8605Smrg/** Client requested a flag or combination of flags the driver can't do. */
1200848b8605Smrg#define __DRI_CTX_ERROR_BAD_FLAG		4
1201848b8605Smrg
1202848b8605Smrg/** Client requested an attribute the driver doesn't understand. */
1203848b8605Smrg#define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE	5
1204848b8605Smrg
1205848b8605Smrg/** Client requested a flag the driver doesn't understand. */
1206848b8605Smrg#define __DRI_CTX_ERROR_UNKNOWN_FLAG		6
1207848b8605Smrg/*@}*/
1208848b8605Smrg
1209848b8605Smrgstruct __DRIdri2ExtensionRec {
1210848b8605Smrg    __DRIextension base;
1211848b8605Smrg
1212848b8605Smrg    __DRIscreen *(*createNewScreen)(int screen, int fd,
1213848b8605Smrg				    const __DRIextension **extensions,
1214848b8605Smrg				    const __DRIconfig ***driver_configs,
1215848b8605Smrg				    void *loaderPrivate);
1216848b8605Smrg
1217848b8605Smrg   __DRIcreateNewDrawableFunc   createNewDrawable;
1218848b8605Smrg   __DRIcontext *(*createNewContext)(__DRIscreen *screen,
1219848b8605Smrg                                     const __DRIconfig *config,
1220848b8605Smrg                                     __DRIcontext *shared,
1221848b8605Smrg                                     void *loaderPrivate);
1222848b8605Smrg
1223848b8605Smrg   /* Since version 2 */
1224848b8605Smrg   __DRIgetAPIMaskFunc          getAPIMask;
1225848b8605Smrg
1226848b8605Smrg   __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
1227848b8605Smrg					   int api,
1228848b8605Smrg					   const __DRIconfig *config,
1229848b8605Smrg					   __DRIcontext *shared,
1230848b8605Smrg					   void *data);
1231848b8605Smrg
1232848b8605Smrg   __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
1233848b8605Smrg				  unsigned int attachment,
1234848b8605Smrg				  unsigned int format,
1235848b8605Smrg				  int width,
1236848b8605Smrg				  int height);
1237848b8605Smrg   void (*releaseBuffer)(__DRIscreen *screen,
1238848b8605Smrg			 __DRIbuffer *buffer);
1239848b8605Smrg
1240848b8605Smrg   /**
1241848b8605Smrg    * Create a context for a particular API with a set of attributes
1242848b8605Smrg    *
1243848b8605Smrg    * \since version 3
1244848b8605Smrg    *
1245848b8605Smrg    * \sa __DRIswrastExtensionRec::createContextAttribs
1246848b8605Smrg    */
1247848b8605Smrg   __DRIcreateContextAttribsFunc        createContextAttribs;
1248848b8605Smrg
1249848b8605Smrg   /**
1250848b8605Smrg    * createNewScreen with the driver's extension list passed in.
1251848b8605Smrg    *
1252848b8605Smrg    * \since version 4
1253848b8605Smrg    */
1254848b8605Smrg   __DRIcreateNewScreen2Func            createNewScreen2;
1255848b8605Smrg};
1256848b8605Smrg
1257848b8605Smrg
1258848b8605Smrg/**
1259848b8605Smrg * This extension provides functionality to enable various EGLImage
1260848b8605Smrg * extensions.
1261848b8605Smrg */
1262848b8605Smrg#define __DRI_IMAGE "DRI_IMAGE"
1263b8e80941Smrg#define __DRI_IMAGE_VERSION 17
1264848b8605Smrg
1265848b8605Smrg/**
1266848b8605Smrg * These formats correspond to the similarly named MESA_FORMAT_*
1267848b8605Smrg * tokens, except in the native endian of the CPU.  For example, on
1268848b8605Smrg * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
1269848b8605Smrg * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
1270848b8605Smrg *
1271848b8605Smrg * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
1272848b8605Smrg * by the driver (YUV planar formats) but serve as a base image for
1273848b8605Smrg * creating sub-images for the different planes within the image.
1274848b8605Smrg *
1275b8e80941Smrg * R8, GR88 and NONE should not be used with createImageFromName or
1276848b8605Smrg * createImage, and are returned by query from sub images created with
1277848b8605Smrg * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
1278848b8605Smrg */
1279848b8605Smrg#define __DRI_IMAGE_FORMAT_RGB565       0x1001
1280848b8605Smrg#define __DRI_IMAGE_FORMAT_XRGB8888     0x1002
1281848b8605Smrg#define __DRI_IMAGE_FORMAT_ARGB8888     0x1003
1282848b8605Smrg#define __DRI_IMAGE_FORMAT_ABGR8888     0x1004
1283848b8605Smrg#define __DRI_IMAGE_FORMAT_XBGR8888     0x1005
1284848b8605Smrg#define __DRI_IMAGE_FORMAT_R8           0x1006 /* Since version 5 */
1285848b8605Smrg#define __DRI_IMAGE_FORMAT_GR88         0x1007
1286848b8605Smrg#define __DRI_IMAGE_FORMAT_NONE         0x1008
1287848b8605Smrg#define __DRI_IMAGE_FORMAT_XRGB2101010  0x1009
1288848b8605Smrg#define __DRI_IMAGE_FORMAT_ARGB2101010  0x100a
1289848b8605Smrg#define __DRI_IMAGE_FORMAT_SARGB8       0x100b
1290b8e80941Smrg#define __DRI_IMAGE_FORMAT_ARGB1555     0x100c
1291b8e80941Smrg#define __DRI_IMAGE_FORMAT_R16          0x100d
1292b8e80941Smrg#define __DRI_IMAGE_FORMAT_GR1616       0x100e
1293b8e80941Smrg#define __DRI_IMAGE_FORMAT_YUYV         0x100f
1294b8e80941Smrg#define __DRI_IMAGE_FORMAT_XBGR2101010  0x1010
1295b8e80941Smrg#define __DRI_IMAGE_FORMAT_ABGR2101010  0x1011
1296b8e80941Smrg#define __DRI_IMAGE_FORMAT_SABGR8       0x1012
1297b8e80941Smrg#define __DRI_IMAGE_FORMAT_UYVY         0x1013
1298848b8605Smrg
1299848b8605Smrg#define __DRI_IMAGE_USE_SHARE		0x0001
1300848b8605Smrg#define __DRI_IMAGE_USE_SCANOUT		0x0002
1301b8e80941Smrg#define __DRI_IMAGE_USE_CURSOR		0x0004 /* Deprecated */
1302848b8605Smrg#define __DRI_IMAGE_USE_LINEAR		0x0008
1303b8e80941Smrg/* The buffer will only be read by an external process after SwapBuffers,
1304b8e80941Smrg * in contrary to gbm buffers, front buffers and fake front buffers, which
1305b8e80941Smrg * could be read after a flush."
1306b8e80941Smrg */
1307b8e80941Smrg#define __DRI_IMAGE_USE_BACKBUFFER      0x0010
1308b8e80941Smrg
1309848b8605Smrg
1310b8e80941Smrg#define __DRI_IMAGE_TRANSFER_READ            0x1
1311b8e80941Smrg#define __DRI_IMAGE_TRANSFER_WRITE           0x2
1312b8e80941Smrg#define __DRI_IMAGE_TRANSFER_READ_WRITE      \
1313b8e80941Smrg        (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)
1314848b8605Smrg
1315848b8605Smrg/**
1316b8e80941Smrg * Four CC formats that matches with WL_DRM_FORMAT_* from wayland_drm.h,
1317b8e80941Smrg * GBM_FORMAT_* from gbm.h, and DRM_FORMAT_* from drm_fourcc.h. Used with
1318b8e80941Smrg * createImageFromNames.
1319848b8605Smrg *
1320848b8605Smrg * \since 5
1321848b8605Smrg */
1322848b8605Smrg
1323b8e80941Smrg#define __DRI_IMAGE_FOURCC_R8		0x20203852
1324b8e80941Smrg#define __DRI_IMAGE_FOURCC_GR88		0x38385247
1325b8e80941Smrg#define __DRI_IMAGE_FOURCC_ARGB1555	0x35315241
1326b8e80941Smrg#define __DRI_IMAGE_FOURCC_R16		0x20363152
1327b8e80941Smrg#define __DRI_IMAGE_FOURCC_GR1616	0x32335247
1328848b8605Smrg#define __DRI_IMAGE_FOURCC_RGB565	0x36314752
1329848b8605Smrg#define __DRI_IMAGE_FOURCC_ARGB8888	0x34325241
1330848b8605Smrg#define __DRI_IMAGE_FOURCC_XRGB8888	0x34325258
1331848b8605Smrg#define __DRI_IMAGE_FOURCC_ABGR8888	0x34324241
1332848b8605Smrg#define __DRI_IMAGE_FOURCC_XBGR8888	0x34324258
1333b8e80941Smrg#define __DRI_IMAGE_FOURCC_SARGB8888	0x83324258
1334b8e80941Smrg#define __DRI_IMAGE_FOURCC_SABGR8888	0x84324258
1335b8e80941Smrg#define __DRI_IMAGE_FOURCC_ARGB2101010	0x30335241
1336b8e80941Smrg#define __DRI_IMAGE_FOURCC_XRGB2101010	0x30335258
1337b8e80941Smrg#define __DRI_IMAGE_FOURCC_ABGR2101010	0x30334241
1338b8e80941Smrg#define __DRI_IMAGE_FOURCC_XBGR2101010	0x30334258
1339b8e80941Smrg#define __DRI_IMAGE_FOURCC_RGBA1010102	0x30334152
1340b8e80941Smrg#define __DRI_IMAGE_FOURCC_RGBX1010102	0x30335852
1341b8e80941Smrg#define __DRI_IMAGE_FOURCC_BGRA1010102	0x30334142
1342b8e80941Smrg#define __DRI_IMAGE_FOURCC_BGRX1010102	0x30335842
1343848b8605Smrg#define __DRI_IMAGE_FOURCC_YUV410	0x39565559
1344848b8605Smrg#define __DRI_IMAGE_FOURCC_YUV411	0x31315559
1345848b8605Smrg#define __DRI_IMAGE_FOURCC_YUV420	0x32315559
1346848b8605Smrg#define __DRI_IMAGE_FOURCC_YUV422	0x36315559
1347848b8605Smrg#define __DRI_IMAGE_FOURCC_YUV444	0x34325559
1348848b8605Smrg#define __DRI_IMAGE_FOURCC_NV12		0x3231564e
1349848b8605Smrg#define __DRI_IMAGE_FOURCC_NV16		0x3631564e
1350848b8605Smrg#define __DRI_IMAGE_FOURCC_YUYV		0x56595559
1351b8e80941Smrg#define __DRI_IMAGE_FOURCC_UYVY		0x59565955
1352b8e80941Smrg#define __DRI_IMAGE_FOURCC_AYUV		0x56555941
1353b8e80941Smrg#define __DRI_IMAGE_FOURCC_XYUV8888	0x56555958
1354848b8605Smrg
1355b8e80941Smrg#define __DRI_IMAGE_FOURCC_YVU410	0x39555659
1356b8e80941Smrg#define __DRI_IMAGE_FOURCC_YVU411	0x31315659
1357b8e80941Smrg#define __DRI_IMAGE_FOURCC_YVU420	0x32315659
1358b8e80941Smrg#define __DRI_IMAGE_FOURCC_YVU422	0x36315659
1359b8e80941Smrg#define __DRI_IMAGE_FOURCC_YVU444	0x34325659
1360b8e80941Smrg
1361b8e80941Smrg#define __DRI_IMAGE_FOURCC_P010		0x30313050
1362b8e80941Smrg#define __DRI_IMAGE_FOURCC_P012		0x32313050
1363b8e80941Smrg#define __DRI_IMAGE_FOURCC_P016		0x36313050
1364848b8605Smrg
1365848b8605Smrg/**
1366848b8605Smrg * Queryable on images created by createImageFromNames.
1367848b8605Smrg *
1368848b8605Smrg * RGB and RGBA are may be usable directly as images but its still
1369848b8605Smrg * recommended to call fromPlanar with plane == 0.
1370848b8605Smrg *
1371b8e80941Smrg * Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create
1372848b8605Smrg * usable sub-images, sampling from images return raw YUV data and
1373848b8605Smrg * color conversion needs to be done in the shader.
1374848b8605Smrg *
1375848b8605Smrg * \since 5
1376848b8605Smrg */
1377848b8605Smrg
1378848b8605Smrg#define __DRI_IMAGE_COMPONENTS_RGB	0x3001
1379848b8605Smrg#define __DRI_IMAGE_COMPONENTS_RGBA	0x3002
1380848b8605Smrg#define __DRI_IMAGE_COMPONENTS_Y_U_V	0x3003
1381848b8605Smrg#define __DRI_IMAGE_COMPONENTS_Y_UV	0x3004
1382848b8605Smrg#define __DRI_IMAGE_COMPONENTS_Y_XUXV	0x3005
1383b8e80941Smrg#define __DRI_IMAGE_COMPONENTS_Y_UXVX	0x3008
1384b8e80941Smrg#define __DRI_IMAGE_COMPONENTS_AYUV	0x3009
1385b8e80941Smrg#define __DRI_IMAGE_COMPONENTS_XYUV	0x300A
1386b8e80941Smrg#define __DRI_IMAGE_COMPONENTS_R	0x3006
1387b8e80941Smrg#define __DRI_IMAGE_COMPONENTS_RG	0x3007
1388848b8605Smrg
1389848b8605Smrg
1390848b8605Smrg/**
1391848b8605Smrg * queryImage attributes
1392848b8605Smrg */
1393848b8605Smrg
1394848b8605Smrg#define __DRI_IMAGE_ATTRIB_STRIDE	0x2000
1395848b8605Smrg#define __DRI_IMAGE_ATTRIB_HANDLE	0x2001
1396848b8605Smrg#define __DRI_IMAGE_ATTRIB_NAME		0x2002
1397848b8605Smrg#define __DRI_IMAGE_ATTRIB_FORMAT	0x2003 /* available in versions 3+ */
1398848b8605Smrg#define __DRI_IMAGE_ATTRIB_WIDTH	0x2004 /* available in versions 4+ */
1399848b8605Smrg#define __DRI_IMAGE_ATTRIB_HEIGHT	0x2005
1400848b8605Smrg#define __DRI_IMAGE_ATTRIB_COMPONENTS	0x2006 /* available in versions 5+ */
1401848b8605Smrg#define __DRI_IMAGE_ATTRIB_FD           0x2007 /* available in versions
1402848b8605Smrg                                                * 7+. Each query will return a
1403848b8605Smrg                                                * new fd. */
1404b8e80941Smrg#define __DRI_IMAGE_ATTRIB_FOURCC       0x2008 /* available in versions 11 */
1405b8e80941Smrg#define __DRI_IMAGE_ATTRIB_NUM_PLANES   0x2009 /* available in versions 11 */
1406b8e80941Smrg
1407b8e80941Smrg#define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
1408b8e80941Smrg#define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */
1409b8e80941Smrg#define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */
1410848b8605Smrg
1411848b8605Smrgenum __DRIYUVColorSpace {
1412848b8605Smrg   __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
1413848b8605Smrg   __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
1414848b8605Smrg   __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
1415848b8605Smrg   __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
1416848b8605Smrg};
1417848b8605Smrg
1418848b8605Smrgenum __DRISampleRange {
1419848b8605Smrg   __DRI_YUV_RANGE_UNDEFINED = 0,
1420848b8605Smrg   __DRI_YUV_FULL_RANGE = 0x3282,
1421848b8605Smrg   __DRI_YUV_NARROW_RANGE = 0x3283
1422848b8605Smrg};
1423848b8605Smrg
1424848b8605Smrgenum __DRIChromaSiting {
1425848b8605Smrg   __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
1426848b8605Smrg   __DRI_YUV_CHROMA_SITING_0 = 0x3284,
1427848b8605Smrg   __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
1428848b8605Smrg};
1429848b8605Smrg
1430848b8605Smrg/**
1431b8e80941Smrg * \name Reasons that __DRIimageExtensionRec::createImageFromTexture or
1432b8e80941Smrg * __DRIimageExtensionRec::createImageFromDmaBufs might fail
1433848b8605Smrg */
1434848b8605Smrg/*@{*/
1435848b8605Smrg/** Success! */
1436848b8605Smrg#define __DRI_IMAGE_ERROR_SUCCESS       0
1437848b8605Smrg
1438848b8605Smrg/** Memory allocation failure */
1439848b8605Smrg#define __DRI_IMAGE_ERROR_BAD_ALLOC     1
1440848b8605Smrg
1441b8e80941Smrg/** Client requested an invalid attribute */
1442848b8605Smrg#define __DRI_IMAGE_ERROR_BAD_MATCH     2
1443848b8605Smrg
1444848b8605Smrg/** Client requested an invalid texture object */
1445848b8605Smrg#define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
1446b8e80941Smrg
1447b8e80941Smrg/** Client requested an invalid pitch and/or offset */
1448b8e80941Smrg#define __DRI_IMAGE_ERROR_BAD_ACCESS    4
1449848b8605Smrg/*@}*/
1450848b8605Smrg
1451848b8605Smrg/**
1452848b8605Smrg * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
1453848b8605Smrg */
1454848b8605Smrg/*@{*/
1455848b8605Smrg#define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
1456848b8605Smrg/*@}*/
1457848b8605Smrg
1458848b8605Smrg/**
1459848b8605Smrg * blitImage flags
1460848b8605Smrg */
1461848b8605Smrg
1462848b8605Smrg#define __BLIT_FLAG_FLUSH		0x0001
1463848b8605Smrg#define __BLIT_FLAG_FINISH		0x0002
1464848b8605Smrg
1465b8e80941Smrg/**
1466b8e80941Smrg * queryDmaBufFormatModifierAttribs attributes
1467b8e80941Smrg */
1468b8e80941Smrg
1469b8e80941Smrg/* Available in version 16 */
1470b8e80941Smrg#define __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT   0x0001
1471b8e80941Smrg
1472848b8605Smrgtypedef struct __DRIimageRec          __DRIimage;
1473848b8605Smrgtypedef struct __DRIimageExtensionRec __DRIimageExtension;
1474848b8605Smrgstruct __DRIimageExtensionRec {
1475848b8605Smrg    __DRIextension base;
1476848b8605Smrg
1477848b8605Smrg    __DRIimage *(*createImageFromName)(__DRIscreen *screen,
1478848b8605Smrg				       int width, int height, int format,
1479848b8605Smrg				       int name, int pitch,
1480848b8605Smrg				       void *loaderPrivate);
1481848b8605Smrg
1482b8e80941Smrg    /* Deprecated since version 17; see createImageFromRenderbuffer2 */
1483848b8605Smrg    __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
1484848b8605Smrg					       int renderbuffer,
1485848b8605Smrg					       void *loaderPrivate);
1486848b8605Smrg
1487848b8605Smrg    void (*destroyImage)(__DRIimage *image);
1488848b8605Smrg
1489848b8605Smrg    __DRIimage *(*createImage)(__DRIscreen *screen,
1490848b8605Smrg			       int width, int height, int format,
1491848b8605Smrg			       unsigned int use,
1492848b8605Smrg			       void *loaderPrivate);
1493848b8605Smrg
1494848b8605Smrg   GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
1495848b8605Smrg
1496848b8605Smrg   /**
1497848b8605Smrg    * The new __DRIimage will share the content with the old one, see dup(2).
1498848b8605Smrg    */
1499848b8605Smrg   __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
1500848b8605Smrg
1501848b8605Smrg   /**
1502848b8605Smrg    * Validate that a __DRIimage can be used a certain way.
1503848b8605Smrg    *
1504848b8605Smrg    * \since 2
1505848b8605Smrg    */
1506848b8605Smrg   GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
1507848b8605Smrg
1508848b8605Smrg   /**
1509848b8605Smrg    * Unlike createImageFromName __DRI_IMAGE_FORMAT is not but instead
1510848b8605Smrg    * __DRI_IMAGE_FOURCC and strides are in bytes not pixels. Stride is
1511848b8605Smrg    * also per block and not per pixel (for non-RGB, see gallium blocks).
1512848b8605Smrg    *
1513848b8605Smrg    * \since 5
1514848b8605Smrg    */
1515848b8605Smrg   __DRIimage *(*createImageFromNames)(__DRIscreen *screen,
1516848b8605Smrg                                       int width, int height, int fourcc,
1517848b8605Smrg                                       int *names, int num_names,
1518848b8605Smrg                                       int *strides, int *offsets,
1519848b8605Smrg                                       void *loaderPrivate);
1520848b8605Smrg
1521848b8605Smrg   /**
1522848b8605Smrg    * Create an image out of a sub-region of a parent image.  This
1523848b8605Smrg    * entry point lets us create individual __DRIimages for different
1524848b8605Smrg    * planes in a planar buffer (typically yuv), for example.  While a
1525848b8605Smrg    * sub-image shares the underlying buffer object with the parent
1526848b8605Smrg    * image and other sibling sub-images, the life times of parent and
1527848b8605Smrg    * sub-images are not dependent.  Destroying the parent or a
1528848b8605Smrg    * sub-image doesn't affect other images.  The underlying buffer
1529848b8605Smrg    * object is free when no __DRIimage remains that references it.
1530848b8605Smrg    *
1531848b8605Smrg    * Sub-images may overlap, but rendering to overlapping sub-images
1532848b8605Smrg    * is undefined.
1533848b8605Smrg    *
1534848b8605Smrg    * \since 5
1535848b8605Smrg    */
1536848b8605Smrg    __DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
1537848b8605Smrg                              void *loaderPrivate);
1538848b8605Smrg
1539848b8605Smrg    /**
1540848b8605Smrg     * Create image from texture.
1541848b8605Smrg     *
1542848b8605Smrg     * \since 6
1543848b8605Smrg     */
1544848b8605Smrg   __DRIimage *(*createImageFromTexture)(__DRIcontext *context,
1545848b8605Smrg                                         int target,
1546848b8605Smrg                                         unsigned texture,
1547848b8605Smrg                                         int depth,
1548848b8605Smrg                                         int level,
1549848b8605Smrg                                         unsigned *error,
1550848b8605Smrg                                         void *loaderPrivate);
1551848b8605Smrg   /**
1552848b8605Smrg    * Like createImageFromNames, but takes a prime fd instead.
1553848b8605Smrg    *
1554848b8605Smrg    * \since 7
1555848b8605Smrg    */
1556848b8605Smrg   __DRIimage *(*createImageFromFds)(__DRIscreen *screen,
1557848b8605Smrg                                     int width, int height, int fourcc,
1558848b8605Smrg                                     int *fds, int num_fds,
1559848b8605Smrg                                     int *strides, int *offsets,
1560848b8605Smrg                                     void *loaderPrivate);
1561848b8605Smrg
1562848b8605Smrg   /**
1563848b8605Smrg    * Like createImageFromFds, but takes additional attributes.
1564848b8605Smrg    *
1565848b8605Smrg    * For EGL_EXT_image_dma_buf_import.
1566848b8605Smrg    *
1567848b8605Smrg    * \since 8
1568848b8605Smrg    */
1569848b8605Smrg   __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
1570848b8605Smrg                                         int width, int height, int fourcc,
1571848b8605Smrg                                         int *fds, int num_fds,
1572848b8605Smrg                                         int *strides, int *offsets,
1573848b8605Smrg                                         enum __DRIYUVColorSpace color_space,
1574848b8605Smrg                                         enum __DRISampleRange sample_range,
1575848b8605Smrg                                         enum __DRIChromaSiting horiz_siting,
1576848b8605Smrg                                         enum __DRIChromaSiting vert_siting,
1577848b8605Smrg                                         unsigned *error,
1578848b8605Smrg                                         void *loaderPrivate);
1579848b8605Smrg
1580848b8605Smrg   /**
1581848b8605Smrg    * Blit a part of a __DRIimage to another and flushes
1582848b8605Smrg    *
1583848b8605Smrg    * flush_flag:
1584848b8605Smrg    *    0:                  no flush
1585848b8605Smrg    *    __BLIT_FLAG_FLUSH:  flush after the blit operation
1586848b8605Smrg    *    __BLIT_FLAG_FINISH: flush and wait the blit finished
1587848b8605Smrg    *
1588848b8605Smrg    * \since 9
1589848b8605Smrg    */
1590848b8605Smrg   void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
1591848b8605Smrg                     int dstx0, int dsty0, int dstwidth, int dstheight,
1592848b8605Smrg                     int srcx0, int srcy0, int srcwidth, int srcheight,
1593848b8605Smrg                     int flush_flag);
1594848b8605Smrg
1595848b8605Smrg   /**
1596848b8605Smrg    * Query for general capabilities of the driver that concern
1597848b8605Smrg    * buffer sharing and image importing.
1598848b8605Smrg    *
1599848b8605Smrg    * \since 10
1600848b8605Smrg    */
1601848b8605Smrg   int (*getCapabilities)(__DRIscreen *screen);
1602b8e80941Smrg
1603b8e80941Smrg   /**
1604b8e80941Smrg    * Returns a map of the specified region of a __DRIimage for the specified usage.
1605b8e80941Smrg    *
1606b8e80941Smrg    * flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the
1607b8e80941Smrg    * mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ
1608b8e80941Smrg    * is not included in the flags, the buffer content at map time is
1609b8e80941Smrg    * undefined. Users wanting to modify the mapping must include
1610b8e80941Smrg    * __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not
1611b8e80941Smrg    * included, behaviour when writing the mapping is undefined.
1612b8e80941Smrg    *
1613b8e80941Smrg    * Returns the byte stride in *stride, and an opaque pointer to data
1614b8e80941Smrg    * tracking the mapping in **data, which must be passed to unmapImage().
1615b8e80941Smrg    *
1616b8e80941Smrg    * \since 12
1617b8e80941Smrg    */
1618b8e80941Smrg   void *(*mapImage)(__DRIcontext *context, __DRIimage *image,
1619b8e80941Smrg                     int x0, int y0, int width, int height,
1620b8e80941Smrg                     unsigned int flags, int *stride, void **data);
1621b8e80941Smrg
1622b8e80941Smrg   /**
1623b8e80941Smrg    * Unmap a previously mapped __DRIimage
1624b8e80941Smrg    *
1625b8e80941Smrg    * \since 12
1626b8e80941Smrg    */
1627b8e80941Smrg   void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);
1628b8e80941Smrg
1629b8e80941Smrg
1630b8e80941Smrg   /**
1631b8e80941Smrg    * Creates an image with implementation's favorite modifiers.
1632b8e80941Smrg    *
1633b8e80941Smrg    * This acts like createImage except there is a list of modifiers passed in
1634b8e80941Smrg    * which the implementation may selectively use to create the DRIimage. The
1635b8e80941Smrg    * result should be the implementation selects one modifier (perhaps it would
1636b8e80941Smrg    * hold on to a few and later pick).
1637b8e80941Smrg    *
1638b8e80941Smrg    * The created image should be destroyed with destroyImage().
1639b8e80941Smrg    *
1640b8e80941Smrg    * Returns the new DRIimage. The chosen modifier can be obtained later on
1641b8e80941Smrg    * and passed back to things like the kernel's AddFB2 interface.
1642b8e80941Smrg    *
1643b8e80941Smrg    * \sa __DRIimageRec::createImage
1644b8e80941Smrg    *
1645b8e80941Smrg    * \since 14
1646b8e80941Smrg    */
1647b8e80941Smrg   __DRIimage *(*createImageWithModifiers)(__DRIscreen *screen,
1648b8e80941Smrg                                           int width, int height, int format,
1649b8e80941Smrg                                           const uint64_t *modifiers,
1650b8e80941Smrg                                           const unsigned int modifier_count,
1651b8e80941Smrg                                           void *loaderPrivate);
1652b8e80941Smrg
1653b8e80941Smrg   /*
1654b8e80941Smrg    * Like createImageFromDmaBufs, but takes also format modifiers.
1655b8e80941Smrg    *
1656b8e80941Smrg    * For EGL_EXT_image_dma_buf_import_modifiers.
1657b8e80941Smrg    *
1658b8e80941Smrg    * \since 15
1659b8e80941Smrg    */
1660b8e80941Smrg   __DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen,
1661b8e80941Smrg                                          int width, int height, int fourcc,
1662b8e80941Smrg                                          uint64_t modifier,
1663b8e80941Smrg                                          int *fds, int num_fds,
1664b8e80941Smrg                                          int *strides, int *offsets,
1665b8e80941Smrg                                          enum __DRIYUVColorSpace color_space,
1666b8e80941Smrg                                          enum __DRISampleRange sample_range,
1667b8e80941Smrg                                          enum __DRIChromaSiting horiz_siting,
1668b8e80941Smrg                                          enum __DRIChromaSiting vert_siting,
1669b8e80941Smrg                                          unsigned *error,
1670b8e80941Smrg                                          void *loaderPrivate);
1671b8e80941Smrg
1672b8e80941Smrg   /*
1673b8e80941Smrg    * dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers.
1674b8e80941Smrg    *
1675b8e80941Smrg    * \param max      Maximum number of formats that can be accomodated into
1676b8e80941Smrg    *                 \param formats. If zero, no formats are returned -
1677b8e80941Smrg    *                 instead, the driver returns the total number of
1678b8e80941Smrg    *                 supported dmabuf formats in \param count.
1679b8e80941Smrg    * \param formats  Buffer to fill formats into.
1680b8e80941Smrg    * \param count    Count of formats returned, or, total number of
1681b8e80941Smrg    *                 supported formats in case \param max is zero.
1682b8e80941Smrg    *
1683b8e80941Smrg    * Returns true on success.
1684b8e80941Smrg    *
1685b8e80941Smrg    * \since 15
1686b8e80941Smrg    */
1687b8e80941Smrg   GLboolean (*queryDmaBufFormats)(__DRIscreen *screen, int max,
1688b8e80941Smrg                                   int *formats, int *count);
1689b8e80941Smrg
1690b8e80941Smrg   /*
1691b8e80941Smrg    * dmabuf format modifier query for a given format to support
1692b8e80941Smrg    * EGL_EXT_image_dma_buf_import_modifiers.
1693b8e80941Smrg    *
1694b8e80941Smrg    * \param fourcc    The format to query modifiers for. If this format
1695b8e80941Smrg    *                  is not supported by the driver, return false.
1696b8e80941Smrg    * \param max       Maximum number of modifiers that can be accomodated in
1697b8e80941Smrg    *                  \param modifiers. If zero, no modifiers are returned -
1698b8e80941Smrg    *                  instead, the driver returns the total number of
1699b8e80941Smrg    *                  modifiers for \param format in \param count.
1700b8e80941Smrg    * \param modifiers Buffer to fill modifiers into.
1701b8e80941Smrg    * \param count     Count of the modifiers returned, or, total number of
1702b8e80941Smrg    *                  supported modifiers for \param fourcc in case
1703b8e80941Smrg    *                  \param max is zero.
1704b8e80941Smrg    *
1705b8e80941Smrg    * Returns true upon success.
1706b8e80941Smrg    *
1707b8e80941Smrg    * \since 15
1708b8e80941Smrg    */
1709b8e80941Smrg   GLboolean (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc,
1710b8e80941Smrg                                     int max, uint64_t *modifiers,
1711b8e80941Smrg                                     unsigned int *external_only,
1712b8e80941Smrg                                     int *count);
1713b8e80941Smrg
1714b8e80941Smrg   /**
1715b8e80941Smrg    * dmabuf format modifier attribute query for a given format and modifier.
1716b8e80941Smrg    *
1717b8e80941Smrg    * \param fourcc    The format to query. If this format is not supported by
1718b8e80941Smrg    *                  the driver, return false.
1719b8e80941Smrg    * \param modifier  The modifier to query. If this format+modifier is not
1720b8e80941Smrg    *                  supported by the driver, return false.
1721b8e80941Smrg    * \param attrib    The __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB to query.
1722b8e80941Smrg    * \param value     A pointer to where to store the result of the query.
1723b8e80941Smrg    *
1724b8e80941Smrg    * Returns true upon success.
1725b8e80941Smrg    *
1726b8e80941Smrg    * \since 16
1727b8e80941Smrg    */
1728b8e80941Smrg   GLboolean (*queryDmaBufFormatModifierAttribs)(__DRIscreen *screen,
1729b8e80941Smrg                                                 uint32_t fourcc, uint64_t modifier,
1730b8e80941Smrg                                                 int attrib, uint64_t *value);
1731b8e80941Smrg
1732b8e80941Smrg   /**
1733b8e80941Smrg    * Create a DRI image from the given renderbuffer.
1734b8e80941Smrg    *
1735b8e80941Smrg    * \param context       the current DRI context
1736b8e80941Smrg    * \param renderbuffer  the GL name of the renderbuffer
1737b8e80941Smrg    * \param loaderPrivate for callbacks into the loader related to the image
1738b8e80941Smrg    * \param error         will be set to one of __DRI_IMAGE_ERROR_xxx
1739b8e80941Smrg    * \return the newly created image on success, or NULL otherwise
1740b8e80941Smrg    *
1741b8e80941Smrg    * \since 17
1742b8e80941Smrg    */
1743b8e80941Smrg    __DRIimage *(*createImageFromRenderbuffer2)(__DRIcontext *context,
1744b8e80941Smrg                                                int renderbuffer,
1745b8e80941Smrg                                                void *loaderPrivate,
1746b8e80941Smrg                                                unsigned *error);
1747848b8605Smrg};
1748848b8605Smrg
1749848b8605Smrg
1750848b8605Smrg/**
1751848b8605Smrg * This extension must be implemented by the loader and passed to the
1752848b8605Smrg * driver at screen creation time.  The EGLImage entry points in the
1753848b8605Smrg * various client APIs take opaque EGLImage handles and use this
1754848b8605Smrg * extension to map them to a __DRIimage.  At version 1, this
1755848b8605Smrg * extensions allows mapping EGLImage pointers to __DRIimage pointers,
1756848b8605Smrg * but future versions could support other EGLImage-like, opaque types
1757848b8605Smrg * with new lookup functions.
1758848b8605Smrg */
1759848b8605Smrg#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
1760848b8605Smrg#define __DRI_IMAGE_LOOKUP_VERSION 1
1761848b8605Smrg
1762848b8605Smrgtypedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
1763848b8605Smrgstruct __DRIimageLookupExtensionRec {
1764848b8605Smrg    __DRIextension base;
1765848b8605Smrg
1766848b8605Smrg    __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
1767848b8605Smrg				  void *loaderPrivate);
1768848b8605Smrg};
1769848b8605Smrg
1770848b8605Smrg/**
1771848b8605Smrg * This extension allows for common DRI2 options
1772848b8605Smrg */
1773848b8605Smrg#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
1774848b8605Smrg#define __DRI2_CONFIG_QUERY_VERSION 1
1775848b8605Smrg
1776848b8605Smrgtypedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
1777848b8605Smrgstruct __DRI2configQueryExtensionRec {
1778848b8605Smrg   __DRIextension base;
1779848b8605Smrg
1780848b8605Smrg   int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);
1781848b8605Smrg   int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
1782848b8605Smrg   int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
1783848b8605Smrg};
1784848b8605Smrg
1785848b8605Smrg/**
1786848b8605Smrg * Robust context driver extension.
1787848b8605Smrg *
1788848b8605Smrg * Existence of this extension means the driver can accept the
1789848b8605Smrg * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
1790848b8605Smrg * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
1791848b8605Smrg * \c __DRIdri2ExtensionRec::createContextAttribs.
1792848b8605Smrg */
1793848b8605Smrg#define __DRI2_ROBUSTNESS "DRI_Robustness"
1794848b8605Smrg#define __DRI2_ROBUSTNESS_VERSION 1
1795848b8605Smrg
1796848b8605Smrgtypedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
1797848b8605Smrgstruct __DRIrobustnessExtensionRec {
1798848b8605Smrg   __DRIextension base;
1799848b8605Smrg};
1800848b8605Smrg
1801b8e80941Smrg/**
1802b8e80941Smrg * No-error context driver extension.
1803b8e80941Smrg *
1804b8e80941Smrg * Existence of this extension means the driver can accept the
1805b8e80941Smrg * __DRI_CTX_FLAG_NO_ERROR flag.
1806b8e80941Smrg */
1807b8e80941Smrg#define __DRI2_NO_ERROR "DRI_NoError"
1808b8e80941Smrg#define __DRI2_NO_ERROR_VERSION 1
1809b8e80941Smrg
1810b8e80941Smrgtypedef struct __DRInoErrorExtensionRec {
1811b8e80941Smrg   __DRIextension base;
1812b8e80941Smrg} __DRInoErrorExtension;
1813b8e80941Smrg
1814b8e80941Smrg/*
1815b8e80941Smrg * Flush control driver extension.
1816b8e80941Smrg *
1817b8e80941Smrg * Existence of this extension means the driver can accept the
1818b8e80941Smrg * \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in
1819b8e80941Smrg * \c __DRIdri2ExtensionRec::createContextAttribs.
1820b8e80941Smrg */
1821b8e80941Smrg#define __DRI2_FLUSH_CONTROL "DRI_FlushControl"
1822b8e80941Smrg#define __DRI2_FLUSH_CONTROL_VERSION 1
1823b8e80941Smrg
1824b8e80941Smrgtypedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension;
1825b8e80941Smrgstruct __DRI2flushControlExtensionRec {
1826b8e80941Smrg   __DRIextension base;
1827b8e80941Smrg};
1828b8e80941Smrg
1829848b8605Smrg/**
1830848b8605Smrg * DRI config options extension.
1831848b8605Smrg *
1832848b8605Smrg * This extension provides the XML string containing driver options for use by
1833848b8605Smrg * the loader in supporting the driconf application.
1834b8e80941Smrg *
1835b8e80941Smrg * v2:
1836b8e80941Smrg * - Add the getXml getter function which allows the driver more flexibility in
1837b8e80941Smrg *   how the XML is provided.
1838b8e80941Smrg * - Deprecate the direct xml pointer. It is only provided as a fallback for
1839b8e80941Smrg *   older versions of libGL and must not be used by clients that are aware of
1840b8e80941Smrg *   the newer version. Future driver versions may set it to NULL.
1841848b8605Smrg */
1842848b8605Smrg#define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
1843b8e80941Smrg#define __DRI_CONFIG_OPTIONS_VERSION 2
1844848b8605Smrg
1845848b8605Smrgtypedef struct __DRIconfigOptionsExtensionRec {
1846848b8605Smrg   __DRIextension base;
1847b8e80941Smrg   const char *xml; /**< deprecated since v2, use getXml instead */
1848b8e80941Smrg
1849b8e80941Smrg   /**
1850b8e80941Smrg    * Get an XML string that describes available driver options for use by a
1851b8e80941Smrg    * config application.
1852b8e80941Smrg    *
1853b8e80941Smrg    * The returned string must be heap-allocated. The caller is responsible for
1854b8e80941Smrg    * freeing it.
1855b8e80941Smrg    */
1856b8e80941Smrg   char *(*getXml)(const char *driver_name);
1857848b8605Smrg} __DRIconfigOptionsExtension;
1858848b8605Smrg
1859848b8605Smrg/**
1860848b8605Smrg * This extension provides a driver vtable to a set of common driver helper
1861848b8605Smrg * functions (driCoreExtension, driDRI2Extension) within the driver
1862848b8605Smrg * implementation, as opposed to having to pass them through a global
1863848b8605Smrg * variable.
1864848b8605Smrg *
1865848b8605Smrg * It is not intended to be public API to the actual loader, and the vtable
1866848b8605Smrg * layout may change at any time.
1867848b8605Smrg */
1868848b8605Smrg#define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
1869848b8605Smrg#define __DRI_DRIVER_VTABLE_VERSION 1
1870848b8605Smrg
1871848b8605Smrgtypedef struct __DRIDriverVtableExtensionRec {
1872848b8605Smrg    __DRIextension base;
1873848b8605Smrg    const struct __DriverAPIRec *vtable;
1874848b8605Smrg} __DRIDriverVtableExtension;
1875848b8605Smrg
1876848b8605Smrg/**
1877848b8605Smrg * Query renderer driver extension
1878848b8605Smrg *
1879848b8605Smrg * This allows the window system layer (either EGL or GLX) to query aspects of
1880848b8605Smrg * hardware and driver support without creating a context.
1881848b8605Smrg */
1882848b8605Smrg#define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
1883848b8605Smrg#define __DRI2_RENDERER_QUERY_VERSION 1
1884848b8605Smrg
1885848b8605Smrg#define __DRI2_RENDERER_VENDOR_ID                             0x0000
1886848b8605Smrg#define __DRI2_RENDERER_DEVICE_ID                             0x0001
1887848b8605Smrg#define __DRI2_RENDERER_VERSION                               0x0002
1888848b8605Smrg#define __DRI2_RENDERER_ACCELERATED                           0x0003
1889848b8605Smrg#define __DRI2_RENDERER_VIDEO_MEMORY                          0x0004
1890848b8605Smrg#define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE           0x0005
1891848b8605Smrg#define __DRI2_RENDERER_PREFERRED_PROFILE                     0x0006
1892848b8605Smrg#define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION           0x0007
1893848b8605Smrg#define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION  0x0008
1894848b8605Smrg#define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION             0x0009
1895848b8605Smrg#define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION            0x000a
1896b8e80941Smrg#define __DRI2_RENDERER_HAS_TEXTURE_3D                        0x000b
1897b8e80941Smrg/* Whether there is an sRGB format support for every supported 32-bit UNORM
1898b8e80941Smrg * color format.
1899b8e80941Smrg */
1900b8e80941Smrg#define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB                  0x000c
1901b8e80941Smrg
1902b8e80941Smrg/* Bitmaks of supported/available context priorities - must match
1903b8e80941Smrg * __EGL_CONTEXT_PRIORITY_LOW_BIT et al
1904b8e80941Smrg */
1905b8e80941Smrg#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY                  0x000d
1906b8e80941Smrg#define   __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW            (1 << 0)
1907b8e80941Smrg#define   __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM         (1 << 1)
1908b8e80941Smrg#define   __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH           (1 << 2)
1909848b8605Smrg
1910848b8605Smrgtypedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
1911848b8605Smrgstruct __DRI2rendererQueryExtensionRec {
1912848b8605Smrg   __DRIextension base;
1913848b8605Smrg
1914848b8605Smrg   int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
1915848b8605Smrg   int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
1916848b8605Smrg};
1917848b8605Smrg
1918848b8605Smrg/**
1919848b8605Smrg * Image Loader extension. Drivers use this to allocate color buffers
1920848b8605Smrg */
1921848b8605Smrg
1922b8e80941Smrg/**
1923b8e80941Smrg * See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask.
1924b8e80941Smrg */
1925848b8605Smrgenum __DRIimageBufferMask {
1926848b8605Smrg   __DRI_IMAGE_BUFFER_BACK = (1 << 0),
1927b8e80941Smrg   __DRI_IMAGE_BUFFER_FRONT = (1 << 1),
1928b8e80941Smrg
1929b8e80941Smrg   /**
1930b8e80941Smrg    * A buffer shared between application and compositor. The buffer may be
1931b8e80941Smrg    * simultaneously accessed by each.
1932b8e80941Smrg    *
1933b8e80941Smrg    * A shared buffer is equivalent to an EGLSurface whose EGLConfig contains
1934b8e80941Smrg    * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as
1935b8e80941Smrg    * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
1936b8e80941Smrg    * EGL_SINGLE_BUFFER.
1937b8e80941Smrg    *
1938b8e80941Smrg    * If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no
1939b8e80941Smrg    * other bits. As a corollary, a __DRIdrawable that has a "shared" buffer
1940b8e80941Smrg    * has no front nor back buffer.
1941b8e80941Smrg    *
1942b8e80941Smrg    * The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only
1943b8e80941Smrg    * if:
1944b8e80941Smrg    *     - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER.
1945b8e80941Smrg    *     - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER.
1946b8e80941Smrg    *     - The EGLConfig of the drawable EGLSurface contains
1947b8e80941Smrg    *       EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.
1948b8e80941Smrg    *     - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER.
1949b8e80941Smrg    *       Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as
1950b8e80941Smrg    *       opposed to any pending, requested change to EGL_RENDER_BUFFER) is
1951b8e80941Smrg    *       EGL_SINGLE_BUFFER. (See the EGL 1.5 and
1952b8e80941Smrg    *       EGL_KHR_mutable_render_buffer spec for details about "pending" vs
1953b8e80941Smrg    *       "active" EGL_RENDER_BUFFER state).
1954b8e80941Smrg    *
1955b8e80941Smrg    * A shared buffer is similar to a front buffer in that all rendering to the
1956b8e80941Smrg    * buffer should appear promptly on the screen. It is different from
1957b8e80941Smrg    * a front buffer in that its behavior is independent from the
1958b8e80941Smrg    * GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the
1959b8e80941Smrg    * __DRIdrawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all
1960b8e80941Smrg    * rendering should appear promptly on the screen if GL_DRAW_BUFFER is not
1961b8e80941Smrg    * GL_NONE.
1962b8e80941Smrg    *
1963b8e80941Smrg    * The difference between a shared buffer and a front buffer is motivated
1964b8e80941Smrg    * by the constraints of Android and OpenGL ES. OpenGL ES does not support
1965b8e80941Smrg    * front-buffer rendering. Android's SurfaceFlinger protocol provides the
1966b8e80941Smrg    * EGL driver only a back buffer and no front buffer. The shared buffer
1967b8e80941Smrg    * mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though
1968b8e80941Smrg    * EGL that allows Android OpenGL ES applications to render to what is
1969b8e80941Smrg    * effectively the front buffer, a backdoor that required no change to the
1970b8e80941Smrg    * OpenGL ES API and little change to the SurfaceFlinger API.
1971b8e80941Smrg    */
1972b8e80941Smrg   __DRI_IMAGE_BUFFER_SHARED = (1 << 2),
1973848b8605Smrg};
1974848b8605Smrg
1975848b8605Smrgstruct __DRIimageList {
1976848b8605Smrg   uint32_t image_mask;
1977848b8605Smrg   __DRIimage *back;
1978848b8605Smrg   __DRIimage *front;
1979848b8605Smrg};
1980848b8605Smrg
1981848b8605Smrg#define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
1982b8e80941Smrg#define __DRI_IMAGE_LOADER_VERSION 3
1983848b8605Smrg
1984848b8605Smrgstruct __DRIimageLoaderExtensionRec {
1985848b8605Smrg    __DRIextension base;
1986848b8605Smrg
1987848b8605Smrg   /**
1988848b8605Smrg    * Allocate color buffers.
1989848b8605Smrg    *
1990848b8605Smrg    * \param driDrawable
1991848b8605Smrg    * \param width              Width of allocated buffers
1992848b8605Smrg    * \param height             Height of allocated buffers
1993848b8605Smrg    * \param format             one of __DRI_IMAGE_FORMAT_*
1994848b8605Smrg    * \param stamp              Address of variable to be updated when
1995848b8605Smrg    *                           getBuffers must be called again
1996848b8605Smrg    * \param loaderPrivate      The loaderPrivate for driDrawable
1997b8e80941Smrg    * \param buffer_mask        Set of buffers to allocate. A bitmask of
1998b8e80941Smrg    *                           __DRIimageBufferMask.
1999848b8605Smrg    * \param buffers            Returned buffers
2000848b8605Smrg    */
2001848b8605Smrg   int (*getBuffers)(__DRIdrawable *driDrawable,
2002848b8605Smrg                     unsigned int format,
2003848b8605Smrg                     uint32_t *stamp,
2004848b8605Smrg                     void *loaderPrivate,
2005848b8605Smrg                     uint32_t buffer_mask,
2006848b8605Smrg                     struct __DRIimageList *buffers);
2007848b8605Smrg
2008848b8605Smrg    /**
2009848b8605Smrg     * Flush pending front-buffer rendering
2010848b8605Smrg     *
2011848b8605Smrg     * Any rendering that has been performed to the
2012848b8605Smrg     * fake front will be flushed to the front
2013848b8605Smrg     *
2014848b8605Smrg     * \param driDrawable    Drawable whose front-buffer is to be flushed
2015848b8605Smrg     * \param loaderPrivate  Loader's private data that was previously passed
2016848b8605Smrg     *                       into __DRIdri2ExtensionRec::createNewDrawable
2017848b8605Smrg     */
2018848b8605Smrg    void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
2019b8e80941Smrg
2020b8e80941Smrg    /**
2021b8e80941Smrg     * Return a loader capability value. If the loader doesn't know the enum,
2022b8e80941Smrg     * it will return 0.
2023b8e80941Smrg     *
2024b8e80941Smrg     * \since 2
2025b8e80941Smrg     */
2026b8e80941Smrg    unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
2027b8e80941Smrg
2028b8e80941Smrg    /**
2029b8e80941Smrg     * Flush swap buffers
2030b8e80941Smrg     *
2031b8e80941Smrg     * Make sure any outstanding swap buffers have been submitted to the
2032b8e80941Smrg     * device.
2033b8e80941Smrg     *
2034b8e80941Smrg     * \param driDrawable    Drawable whose swaps need to be flushed
2035b8e80941Smrg     * \param loaderPrivate  Loader's private data that was previously passed
2036b8e80941Smrg     *                       into __DRIdri2ExtensionRec::createNewDrawable
2037b8e80941Smrg     *
2038b8e80941Smrg     * \since 3
2039b8e80941Smrg     */
2040b8e80941Smrg    void (*flushSwapBuffers)(__DRIdrawable *driDrawable, void *loaderPrivate);
2041848b8605Smrg};
2042848b8605Smrg
2043848b8605Smrg/**
2044848b8605Smrg * DRI extension.
2045848b8605Smrg */
2046848b8605Smrg
2047848b8605Smrg#define __DRI_IMAGE_DRIVER           "DRI_IMAGE_DRIVER"
2048848b8605Smrg#define __DRI_IMAGE_DRIVER_VERSION   1
2049848b8605Smrg
2050848b8605Smrgstruct __DRIimageDriverExtensionRec {
2051848b8605Smrg   __DRIextension               base;
2052848b8605Smrg
2053848b8605Smrg   /* Common DRI functions, shared with DRI2 */
2054848b8605Smrg   __DRIcreateNewScreen2Func            createNewScreen2;
2055848b8605Smrg   __DRIcreateNewDrawableFunc           createNewDrawable;
2056848b8605Smrg   __DRIcreateContextAttribsFunc        createContextAttribs;
2057848b8605Smrg   __DRIgetAPIMaskFunc                  getAPIMask;
2058848b8605Smrg};
2059848b8605Smrg
2060b8e80941Smrg/**
2061b8e80941Smrg * Background callable loader extension.
2062b8e80941Smrg *
2063b8e80941Smrg * Loaders expose this extension to indicate to drivers that they are capable
2064b8e80941Smrg * of handling callbacks from the driver's background drawing threads.
2065b8e80941Smrg */
2066b8e80941Smrg#define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"
2067b8e80941Smrg#define __DRI_BACKGROUND_CALLABLE_VERSION 1
2068b8e80941Smrg
2069b8e80941Smrgtypedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension;
2070b8e80941Smrgstruct __DRIbackgroundCallableExtensionRec {
2071b8e80941Smrg   __DRIextension base;
2072b8e80941Smrg
2073b8e80941Smrg   /**
2074b8e80941Smrg    * Indicate that this thread is being used by the driver as a background
2075b8e80941Smrg    * drawing thread which may make callbacks to the loader.
2076b8e80941Smrg    *
2077b8e80941Smrg    * \param loaderPrivate is the value that was passed to to the driver when
2078b8e80941Smrg    * the context was created.  This can be used by the loader to identify
2079b8e80941Smrg    * which context any callbacks are associated with.
2080b8e80941Smrg    *
2081b8e80941Smrg    * If this function is called more than once from any given thread, each
2082b8e80941Smrg    * subsequent call overrides the loaderPrivate data that was passed in the
2083b8e80941Smrg    * previous call.  The driver can take advantage of this to re-use a
2084b8e80941Smrg    * background thread to perform drawing on behalf of multiple contexts.
2085b8e80941Smrg    *
2086b8e80941Smrg    * It is permissible for the driver to call this function from a
2087b8e80941Smrg    * non-background thread (i.e. a thread that has already been bound to a
2088b8e80941Smrg    * context using __DRIcoreExtensionRec::bindContext()); when this happens,
2089b8e80941Smrg    * the \c loaderPrivate pointer must be equal to the pointer that was
2090b8e80941Smrg    * passed to the driver when the currently bound context was created.
2091b8e80941Smrg    *
2092b8e80941Smrg    * This call should execute quickly enough that the driver can call it with
2093b8e80941Smrg    * impunity whenever a background thread starts performing drawing
2094b8e80941Smrg    * operations (e.g. it should just set a thread-local variable).
2095b8e80941Smrg    */
2096b8e80941Smrg   void (*setBackgroundContext)(void *loaderPrivate);
2097b8e80941Smrg
2098b8e80941Smrg   /**
2099b8e80941Smrg    * Indicate that it is multithread safe to use glthread.  For GLX/EGL
2100b8e80941Smrg    * platforms using Xlib, that involves calling XInitThreads, before
2101b8e80941Smrg    * opening an X display.
2102b8e80941Smrg    *
2103b8e80941Smrg    * Note: only supported if extension version is at least 2.
2104b8e80941Smrg    *
2105b8e80941Smrg    * \param loaderPrivate is the value that was passed to to the driver when
2106b8e80941Smrg    * the context was created.  This can be used by the loader to identify
2107b8e80941Smrg    * which context any callbacks are associated with.
2108b8e80941Smrg    */
2109b8e80941Smrg   GLboolean (*isThreadSafe)(void *loaderPrivate);
2110b8e80941Smrg};
2111b8e80941Smrg
2112b8e80941Smrg/**
2113b8e80941Smrg * The driver portion of EGL_KHR_mutable_render_buffer.
2114b8e80941Smrg *
2115b8e80941Smrg * If the driver creates a __DRIconfig with
2116b8e80941Smrg * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension.
2117b8e80941Smrg *
2118b8e80941Smrg * To support this extension:
2119b8e80941Smrg *
2120b8e80941Smrg *    - The driver should create at least one __DRIconfig with
2121b8e80941Smrg *      __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but
2122b8e80941Smrg *      not required.
2123b8e80941Smrg *
2124b8e80941Smrg *    - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if
2125b8e80941Smrg *      returned by __DRIimageLoaderExtension:getBuffers().
2126b8e80941Smrg *
2127b8e80941Smrg *    - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call
2128b8e80941Smrg *      __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() in
2129b8e80941Smrg *      response to glFlush and glFinish.  (This requirement is not documented
2130b8e80941Smrg *      in EGL_KHR_mutable_render_buffer, but is a de-facto requirement in the
2131b8e80941Smrg *      Android ecosystem. Android applications expect that glFlush will
2132b8e80941Smrg *      immediately display the buffer when in shared buffer mode, and Android
2133b8e80941Smrg *      drivers comply with this expectation).  It :may: call
2134b8e80941Smrg *      displaySharedBuffer() more often than required.
2135b8e80941Smrg *
2136b8e80941Smrg *    - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the
2137b8e80941Smrg *      buffer is always in a format compatible for display because the
2138b8e80941Smrg *      display engine (usually SurfaceFlinger or hwcomposer) may display the
2139b8e80941Smrg *      image at any time, even concurrently with 3D rendering. For example,
2140b8e80941Smrg *      display hardware and the GL hardware may be able to access the buffer
2141b8e80941Smrg *      simultaneously. In particular, if the buffer is compressed then take
2142b8e80941Smrg *      care that SurfaceFlinger and hwcomposer can consume the compression
2143b8e80941Smrg *      format.
2144b8e80941Smrg *
2145b8e80941Smrg * \see __DRI_IMAGE_BUFFER_SHARED
2146b8e80941Smrg * \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER
2147b8e80941Smrg * \see __DRI_MUTABLE_RENDER_BUFFER_LOADER
2148b8e80941Smrg */
2149b8e80941Smrg#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver"
2150b8e80941Smrg#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 1
2151b8e80941Smrg
2152b8e80941Smrgtypedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension;
2153b8e80941Smrgstruct __DRImutableRenderBufferDriverExtensionRec {
2154b8e80941Smrg   __DRIextension base;
2155b8e80941Smrg};
2156b8e80941Smrg
2157b8e80941Smrg/**
2158b8e80941Smrg * The loader portion of EGL_KHR_mutable_render_buffer.
2159b8e80941Smrg *
2160b8e80941Smrg * Requires loader extension DRI_IMAGE_LOADER, through which the loader sends
2161b8e80941Smrg * __DRI_IMAGE_BUFFER_SHARED to the driver.
2162b8e80941Smrg *
2163b8e80941Smrg * \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER
2164b8e80941Smrg */
2165b8e80941Smrg#define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader"
2166b8e80941Smrg#define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 1
2167b8e80941Smrg
2168b8e80941Smrgtypedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension;
2169b8e80941Smrgstruct __DRImutableRenderBufferLoaderExtensionRec {
2170b8e80941Smrg   __DRIextension base;
2171b8e80941Smrg
2172b8e80941Smrg   /**
2173b8e80941Smrg    * Inform the display engine (that is, SurfaceFlinger and/or hwcomposer)
2174b8e80941Smrg    * that the __DRIdrawable has new content.
2175b8e80941Smrg    *
2176b8e80941Smrg    * The display engine may ignore this call, for example, if it continually
2177b8e80941Smrg    * refreshes and displays the buffer on every frame, as in
2178b8e80941Smrg    * EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display
2179b8e80941Smrg    * engine may refresh and display the buffer only in frames in which the
2180b8e80941Smrg    * driver calls this.
2181b8e80941Smrg    *
2182b8e80941Smrg    * If the fence_fd is not -1, then the display engine will display the
2183b8e80941Smrg    * buffer only after the fence signals.
2184b8e80941Smrg    *
2185b8e80941Smrg    * The drawable's current __DRIimageBufferMask, as returned by
2186b8e80941Smrg    * __DRIimageLoaderExtension::getBuffers(), must be
2187b8e80941Smrg    * __DRI_IMAGE_BUFFER_SHARED.
2188b8e80941Smrg    */
2189b8e80941Smrg   void (*displaySharedBuffer)(__DRIdrawable *drawable, int fence_fd,
2190b8e80941Smrg                               void *loaderPrivate);
2191b8e80941Smrg};
2192b8e80941Smrg
2193848b8605Smrg#endif
2194