1bf215546Sopenharmony_ci/*
2bf215546Sopenharmony_ci * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3bf215546Sopenharmony_ci * Copyright 2007-2008 Red Hat, Inc.
4bf215546Sopenharmony_ci * (C) Copyright IBM Corporation 2004
5bf215546Sopenharmony_ci * All Rights Reserved.
6bf215546Sopenharmony_ci *
7bf215546Sopenharmony_ci * Permission is hereby granted, free of charge, to any person obtaining a
8bf215546Sopenharmony_ci * copy of this software and associated documentation files (the "Software"),
9bf215546Sopenharmony_ci * to deal in the Software without restriction, including without limitation
10bf215546Sopenharmony_ci * on the rights to use, copy, modify, merge, publish, distribute, sub
11bf215546Sopenharmony_ci * license, and/or sell copies of the Software, and to permit persons to whom
12bf215546Sopenharmony_ci * the Software is furnished to do so, subject to the following conditions:
13bf215546Sopenharmony_ci *
14bf215546Sopenharmony_ci * The above copyright notice and this permission notice (including the next
15bf215546Sopenharmony_ci * paragraph) shall be included in all copies or substantial portions of the
16bf215546Sopenharmony_ci * Software.
17bf215546Sopenharmony_ci *
18bf215546Sopenharmony_ci * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19bf215546Sopenharmony_ci * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20bf215546Sopenharmony_ci * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
21bf215546Sopenharmony_ci * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22bf215546Sopenharmony_ci * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23bf215546Sopenharmony_ci * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24bf215546Sopenharmony_ci * USE OR OTHER DEALINGS IN THE SOFTWARE.
25bf215546Sopenharmony_ci */
26bf215546Sopenharmony_ci
27bf215546Sopenharmony_ci/**
28bf215546Sopenharmony_ci * \file dri_interface.h
29bf215546Sopenharmony_ci *
30bf215546Sopenharmony_ci * This file contains all the types and functions that define the interface
31bf215546Sopenharmony_ci * between a DRI driver and driver loader.  Currently, the most common driver
32bf215546Sopenharmony_ci * loader is the XFree86 libGL.so.  However, other loaders do exist, and in
33bf215546Sopenharmony_ci * the future the server-side libglx.a will also be a loader.
34bf215546Sopenharmony_ci *
35bf215546Sopenharmony_ci * \author Kevin E. Martin <kevin@precisioninsight.com>
36bf215546Sopenharmony_ci * \author Ian Romanick <idr@us.ibm.com>
37bf215546Sopenharmony_ci * \author Kristian Høgsberg <krh@redhat.com>
38bf215546Sopenharmony_ci */
39bf215546Sopenharmony_ci
40bf215546Sopenharmony_ci#ifndef DRI_INTERFACE_H
41bf215546Sopenharmony_ci#define DRI_INTERFACE_H
42bf215546Sopenharmony_ci
43bf215546Sopenharmony_ci#include <stdint.h>
44bf215546Sopenharmony_ci
45bf215546Sopenharmony_ci/**
46bf215546Sopenharmony_ci * \name DRI interface structures
47bf215546Sopenharmony_ci *
48bf215546Sopenharmony_ci * The following structures define the interface between the GLX client
49bf215546Sopenharmony_ci * side library and the DRI (direct rendering infrastructure).
50bf215546Sopenharmony_ci */
51bf215546Sopenharmony_ci/*@{*/
52bf215546Sopenharmony_citypedef struct __DRIdisplayRec		__DRIdisplay;
53bf215546Sopenharmony_citypedef struct __DRIscreenRec		__DRIscreen;
54bf215546Sopenharmony_citypedef struct __DRIcontextRec		__DRIcontext;
55bf215546Sopenharmony_citypedef struct __DRIdrawableRec		__DRIdrawable;
56bf215546Sopenharmony_citypedef struct __DRIconfigRec		__DRIconfig;
57bf215546Sopenharmony_citypedef struct __DRIframebufferRec	__DRIframebuffer;
58bf215546Sopenharmony_citypedef struct __DRIversionRec		__DRIversion;
59bf215546Sopenharmony_ci
60bf215546Sopenharmony_citypedef struct __DRIcoreExtensionRec		__DRIcoreExtension;
61bf215546Sopenharmony_citypedef struct __DRIextensionRec		__DRIextension;
62bf215546Sopenharmony_citypedef struct __DRIcopySubBufferExtensionRec	__DRIcopySubBufferExtension;
63bf215546Sopenharmony_citypedef struct __DRIswapControlExtensionRec	__DRIswapControlExtension;
64bf215546Sopenharmony_citypedef struct __DRIframeTrackingExtensionRec	__DRIframeTrackingExtension;
65bf215546Sopenharmony_citypedef struct __DRImediaStreamCounterExtensionRec	__DRImediaStreamCounterExtension;
66bf215546Sopenharmony_citypedef struct __DRItexOffsetExtensionRec	__DRItexOffsetExtension;
67bf215546Sopenharmony_citypedef struct __DRItexBufferExtensionRec	__DRItexBufferExtension;
68bf215546Sopenharmony_citypedef struct __DRIlegacyExtensionRec		__DRIlegacyExtension;
69bf215546Sopenharmony_citypedef struct __DRIswrastExtensionRec		__DRIswrastExtension;
70bf215546Sopenharmony_citypedef struct __DRIbufferRec			__DRIbuffer;
71bf215546Sopenharmony_citypedef struct __DRIdri2ExtensionRec		__DRIdri2Extension;
72bf215546Sopenharmony_citypedef struct __DRIdri2LoaderExtensionRec	__DRIdri2LoaderExtension;
73bf215546Sopenharmony_citypedef struct __DRI2flushExtensionRec	__DRI2flushExtension;
74bf215546Sopenharmony_citypedef struct __DRI2throttleExtensionRec	__DRI2throttleExtension;
75bf215546Sopenharmony_citypedef struct __DRI2fenceExtensionRec          __DRI2fenceExtension;
76bf215546Sopenharmony_citypedef struct __DRI2interopExtensionRec	__DRI2interopExtension;
77bf215546Sopenharmony_citypedef struct __DRI2blobExtensionRec           __DRI2blobExtension;
78bf215546Sopenharmony_citypedef struct __DRI2bufferDamageExtensionRec   __DRI2bufferDamageExtension;
79bf215546Sopenharmony_ci
80bf215546Sopenharmony_citypedef struct __DRIimageLoaderExtensionRec     __DRIimageLoaderExtension;
81bf215546Sopenharmony_citypedef struct __DRIimageDriverExtensionRec     __DRIimageDriverExtension;
82bf215546Sopenharmony_ci
83bf215546Sopenharmony_ci/*@}*/
84bf215546Sopenharmony_ci
85bf215546Sopenharmony_ci
86bf215546Sopenharmony_ci/**
87bf215546Sopenharmony_ci * Extension struct.  Drivers 'inherit' from this struct by embedding
88bf215546Sopenharmony_ci * it as the first element in the extension struct.
89bf215546Sopenharmony_ci *
90bf215546Sopenharmony_ci * We never break API in for a DRI extension.  If we need to change
91bf215546Sopenharmony_ci * the way things work in a non-backwards compatible manner, we
92bf215546Sopenharmony_ci * introduce a new extension.  During a transition period, we can
93bf215546Sopenharmony_ci * leave both the old and the new extension in the driver, which
94bf215546Sopenharmony_ci * allows us to move to the new interface without having to update the
95bf215546Sopenharmony_ci * loader(s) in lock step.
96bf215546Sopenharmony_ci *
97bf215546Sopenharmony_ci * However, we can add entry points to an extension over time as long
98bf215546Sopenharmony_ci * as we don't break the old ones.  As we add entry points to an
99bf215546Sopenharmony_ci * extension, we increase the version number.  The corresponding
100bf215546Sopenharmony_ci * #define can be used to guard code that accesses the new entry
101bf215546Sopenharmony_ci * points at compile time and the version field in the extension
102bf215546Sopenharmony_ci * struct can be used at run-time to determine how to use the
103bf215546Sopenharmony_ci * extension.
104bf215546Sopenharmony_ci */
105bf215546Sopenharmony_cistruct __DRIextensionRec {
106bf215546Sopenharmony_ci    const char *name;
107bf215546Sopenharmony_ci    int version;
108bf215546Sopenharmony_ci};
109bf215546Sopenharmony_ci
110bf215546Sopenharmony_ci/**
111bf215546Sopenharmony_ci * The first set of extension are the screen extensions, returned by
112bf215546Sopenharmony_ci * __DRIcore::getExtensions().  This entry point will return a list of
113bf215546Sopenharmony_ci * extensions and the loader can use the ones it knows about by
114bf215546Sopenharmony_ci * casting them to more specific extensions and advertising any GLX
115bf215546Sopenharmony_ci * extensions the DRI extensions enables.
116bf215546Sopenharmony_ci */
117bf215546Sopenharmony_ci
118bf215546Sopenharmony_ci/**
119bf215546Sopenharmony_ci * Used by drivers to indicate support for setting the read drawable.
120bf215546Sopenharmony_ci */
121bf215546Sopenharmony_ci#define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
122bf215546Sopenharmony_ci#define __DRI_READ_DRAWABLE_VERSION 1
123bf215546Sopenharmony_ci
124bf215546Sopenharmony_ci/**
125bf215546Sopenharmony_ci * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
126bf215546Sopenharmony_ci */
127bf215546Sopenharmony_ci#define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
128bf215546Sopenharmony_ci#define __DRI_COPY_SUB_BUFFER_VERSION 1
129bf215546Sopenharmony_cistruct __DRIcopySubBufferExtensionRec {
130bf215546Sopenharmony_ci    __DRIextension base;
131bf215546Sopenharmony_ci    void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);
132bf215546Sopenharmony_ci};
133bf215546Sopenharmony_ci
134bf215546Sopenharmony_ci/**
135bf215546Sopenharmony_ci * Used by drivers that implement the GLX_SGI_swap_control or
136bf215546Sopenharmony_ci * GLX_MESA_swap_control extension.
137bf215546Sopenharmony_ci */
138bf215546Sopenharmony_ci#define __DRI_SWAP_CONTROL "DRI_SwapControl"
139bf215546Sopenharmony_ci#define __DRI_SWAP_CONTROL_VERSION 1
140bf215546Sopenharmony_cistruct __DRIswapControlExtensionRec {
141bf215546Sopenharmony_ci    __DRIextension base;
142bf215546Sopenharmony_ci    void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
143bf215546Sopenharmony_ci    unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
144bf215546Sopenharmony_ci};
145bf215546Sopenharmony_ci
146bf215546Sopenharmony_ci/**
147bf215546Sopenharmony_ci * Used by drivers that implement the GLX_SGI_video_sync extension.
148bf215546Sopenharmony_ci */
149bf215546Sopenharmony_ci#define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
150bf215546Sopenharmony_ci#define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
151bf215546Sopenharmony_cistruct __DRImediaStreamCounterExtensionRec {
152bf215546Sopenharmony_ci    __DRIextension base;
153bf215546Sopenharmony_ci
154bf215546Sopenharmony_ci    /**
155bf215546Sopenharmony_ci     * Wait for the MSC to equal target_msc, or, if that has already passed,
156bf215546Sopenharmony_ci     * the next time (MSC % divisor) is equal to remainder.  If divisor is
157bf215546Sopenharmony_ci     * zero, the function will return as soon as MSC is greater than or equal
158bf215546Sopenharmony_ci     * to target_msc.
159bf215546Sopenharmony_ci     */
160bf215546Sopenharmony_ci    int (*waitForMSC)(__DRIdrawable *drawable,
161bf215546Sopenharmony_ci		      int64_t target_msc, int64_t divisor, int64_t remainder,
162bf215546Sopenharmony_ci		      int64_t * msc, int64_t * sbc);
163bf215546Sopenharmony_ci
164bf215546Sopenharmony_ci    /**
165bf215546Sopenharmony_ci     * Get the number of vertical refreshes since some point in time before
166bf215546Sopenharmony_ci     * this function was first called (i.e., system start up).
167bf215546Sopenharmony_ci     */
168bf215546Sopenharmony_ci    int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
169bf215546Sopenharmony_ci			  int64_t *msc);
170bf215546Sopenharmony_ci};
171bf215546Sopenharmony_ci
172bf215546Sopenharmony_ci/* Valid values for format in the setTexBuffer2 function below.  These
173bf215546Sopenharmony_ci * values match the GLX tokens for compatibility reasons, but we
174bf215546Sopenharmony_ci * define them here since the DRI interface can't depend on GLX. */
175bf215546Sopenharmony_ci#define __DRI_TEXTURE_FORMAT_NONE        0x20D8
176bf215546Sopenharmony_ci#define __DRI_TEXTURE_FORMAT_RGB         0x20D9
177bf215546Sopenharmony_ci#define __DRI_TEXTURE_FORMAT_RGBA        0x20DA
178bf215546Sopenharmony_ci
179bf215546Sopenharmony_ci#define __DRI_TEX_BUFFER "DRI_TexBuffer"
180bf215546Sopenharmony_ci#define __DRI_TEX_BUFFER_VERSION 3
181bf215546Sopenharmony_cistruct __DRItexBufferExtensionRec {
182bf215546Sopenharmony_ci    __DRIextension base;
183bf215546Sopenharmony_ci
184bf215546Sopenharmony_ci    /**
185bf215546Sopenharmony_ci     * Method to override base texture image with the contents of a
186bf215546Sopenharmony_ci     * __DRIdrawable.
187bf215546Sopenharmony_ci     *
188bf215546Sopenharmony_ci     * For GLX_EXT_texture_from_pixmap with AIGLX.  Deprecated in favor of
189bf215546Sopenharmony_ci     * setTexBuffer2 in version 2 of this interface
190bf215546Sopenharmony_ci     */
191bf215546Sopenharmony_ci    void (*setTexBuffer)(__DRIcontext *pDRICtx,
192bf215546Sopenharmony_ci			 int target,
193bf215546Sopenharmony_ci			 __DRIdrawable *pDraw);
194bf215546Sopenharmony_ci
195bf215546Sopenharmony_ci    /**
196bf215546Sopenharmony_ci     * Method to override base texture image with the contents of a
197bf215546Sopenharmony_ci     * __DRIdrawable, including the required texture format attribute.
198bf215546Sopenharmony_ci     *
199bf215546Sopenharmony_ci     * For GLX_EXT_texture_from_pixmap with AIGLX.
200bf215546Sopenharmony_ci     *
201bf215546Sopenharmony_ci     * \since 2
202bf215546Sopenharmony_ci     */
203bf215546Sopenharmony_ci    void (*setTexBuffer2)(__DRIcontext *pDRICtx,
204bf215546Sopenharmony_ci			  int target,
205bf215546Sopenharmony_ci			  int format,
206bf215546Sopenharmony_ci			  __DRIdrawable *pDraw);
207bf215546Sopenharmony_ci    /**
208bf215546Sopenharmony_ci     * Method to release texture buffer in case some special platform
209bf215546Sopenharmony_ci     * need this.
210bf215546Sopenharmony_ci     *
211bf215546Sopenharmony_ci     * For GLX_EXT_texture_from_pixmap with AIGLX.
212bf215546Sopenharmony_ci     *
213bf215546Sopenharmony_ci     * \since 3
214bf215546Sopenharmony_ci     */
215bf215546Sopenharmony_ci    void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
216bf215546Sopenharmony_ci			int target,
217bf215546Sopenharmony_ci			__DRIdrawable *pDraw);
218bf215546Sopenharmony_ci};
219bf215546Sopenharmony_ci
220bf215546Sopenharmony_ci/**
221bf215546Sopenharmony_ci * Used by drivers that implement DRI2
222bf215546Sopenharmony_ci */
223bf215546Sopenharmony_ci#define __DRI2_FLUSH "DRI2_Flush"
224bf215546Sopenharmony_ci#define __DRI2_FLUSH_VERSION 4
225bf215546Sopenharmony_ci
226bf215546Sopenharmony_ci#define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
227bf215546Sopenharmony_ci#define __DRI2_FLUSH_CONTEXT  (1 << 1) /* glFlush should be called */
228bf215546Sopenharmony_ci#define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2)
229bf215546Sopenharmony_ci
230bf215546Sopenharmony_cienum __DRI2throttleReason {
231bf215546Sopenharmony_ci   __DRI2_THROTTLE_SWAPBUFFER,
232bf215546Sopenharmony_ci   __DRI2_THROTTLE_COPYSUBBUFFER,
233bf215546Sopenharmony_ci   __DRI2_THROTTLE_FLUSHFRONT
234bf215546Sopenharmony_ci};
235bf215546Sopenharmony_ci
236bf215546Sopenharmony_cistruct __DRI2flushExtensionRec {
237bf215546Sopenharmony_ci    __DRIextension base;
238bf215546Sopenharmony_ci    void (*flush)(__DRIdrawable *drawable);
239bf215546Sopenharmony_ci
240bf215546Sopenharmony_ci    /**
241bf215546Sopenharmony_ci     * Ask the driver to call getBuffers/getBuffersWithFormat before
242bf215546Sopenharmony_ci     * it starts rendering again.
243bf215546Sopenharmony_ci     *
244bf215546Sopenharmony_ci     * \param drawable the drawable to invalidate
245bf215546Sopenharmony_ci     *
246bf215546Sopenharmony_ci     * \since 3
247bf215546Sopenharmony_ci     */
248bf215546Sopenharmony_ci    void (*invalidate)(__DRIdrawable *drawable);
249bf215546Sopenharmony_ci
250bf215546Sopenharmony_ci    /**
251bf215546Sopenharmony_ci     * This function reduces the number of flushes in the driver by combining
252bf215546Sopenharmony_ci     * several operations into one call.
253bf215546Sopenharmony_ci     *
254bf215546Sopenharmony_ci     * It can:
255bf215546Sopenharmony_ci     * - throttle
256bf215546Sopenharmony_ci     * - flush a drawable
257bf215546Sopenharmony_ci     * - flush a context
258bf215546Sopenharmony_ci     *
259bf215546Sopenharmony_ci     * \param context           the context
260bf215546Sopenharmony_ci     * \param drawable          the drawable to flush
261bf215546Sopenharmony_ci     * \param flags             a combination of _DRI2_FLUSH_xxx flags
262bf215546Sopenharmony_ci     * \param throttle_reason   the reason for throttling, 0 = no throttling
263bf215546Sopenharmony_ci     *
264bf215546Sopenharmony_ci     * \since 4
265bf215546Sopenharmony_ci     */
266bf215546Sopenharmony_ci    void (*flush_with_flags)(__DRIcontext *ctx,
267bf215546Sopenharmony_ci                             __DRIdrawable *drawable,
268bf215546Sopenharmony_ci                             unsigned flags,
269bf215546Sopenharmony_ci                             enum __DRI2throttleReason throttle_reason);
270bf215546Sopenharmony_ci};
271bf215546Sopenharmony_ci
272bf215546Sopenharmony_ci
273bf215546Sopenharmony_ci/**
274bf215546Sopenharmony_ci * Extension that the driver uses to request
275bf215546Sopenharmony_ci * throttle callbacks.
276bf215546Sopenharmony_ci */
277bf215546Sopenharmony_ci
278bf215546Sopenharmony_ci#define __DRI2_THROTTLE "DRI2_Throttle"
279bf215546Sopenharmony_ci#define __DRI2_THROTTLE_VERSION 1
280bf215546Sopenharmony_ci
281bf215546Sopenharmony_cistruct __DRI2throttleExtensionRec {
282bf215546Sopenharmony_ci   __DRIextension base;
283bf215546Sopenharmony_ci   void (*throttle)(__DRIcontext *ctx,
284bf215546Sopenharmony_ci		    __DRIdrawable *drawable,
285bf215546Sopenharmony_ci		    enum __DRI2throttleReason reason);
286bf215546Sopenharmony_ci};
287bf215546Sopenharmony_ci
288bf215546Sopenharmony_ci/**
289bf215546Sopenharmony_ci * Extension for EGL_ANDROID_blob_cache
290bf215546Sopenharmony_ci */
291bf215546Sopenharmony_ci
292bf215546Sopenharmony_ci#define __DRI2_BLOB "DRI2_Blob"
293bf215546Sopenharmony_ci#define __DRI2_BLOB_VERSION 1
294bf215546Sopenharmony_ci
295bf215546Sopenharmony_citypedef void
296bf215546Sopenharmony_ci(*__DRIblobCacheSet) (const void *key, signed long keySize,
297bf215546Sopenharmony_ci                      const void *value, signed long valueSize);
298bf215546Sopenharmony_ci
299bf215546Sopenharmony_citypedef signed long
300bf215546Sopenharmony_ci(*__DRIblobCacheGet) (const void *key, signed long keySize,
301bf215546Sopenharmony_ci                      void *value, signed long valueSize);
302bf215546Sopenharmony_ci
303bf215546Sopenharmony_cistruct __DRI2blobExtensionRec {
304bf215546Sopenharmony_ci   __DRIextension base;
305bf215546Sopenharmony_ci
306bf215546Sopenharmony_ci   /**
307bf215546Sopenharmony_ci    * Set cache functions for setting and getting cache entries.
308bf215546Sopenharmony_ci    */
309bf215546Sopenharmony_ci   void (*set_cache_funcs) (__DRIscreen *screen,
310bf215546Sopenharmony_ci                            __DRIblobCacheSet set, __DRIblobCacheGet get);
311bf215546Sopenharmony_ci};
312bf215546Sopenharmony_ci
313bf215546Sopenharmony_ci/**
314bf215546Sopenharmony_ci * Extension for fences / synchronization objects.
315bf215546Sopenharmony_ci */
316bf215546Sopenharmony_ci
317bf215546Sopenharmony_ci#define __DRI2_FENCE "DRI2_Fence"
318bf215546Sopenharmony_ci#define __DRI2_FENCE_VERSION 2
319bf215546Sopenharmony_ci
320bf215546Sopenharmony_ci#define __DRI2_FENCE_TIMEOUT_INFINITE     0xffffffffffffffffull
321bf215546Sopenharmony_ci
322bf215546Sopenharmony_ci#define __DRI2_FENCE_FLAG_FLUSH_COMMANDS  (1 << 0)
323bf215546Sopenharmony_ci
324bf215546Sopenharmony_ci/**
325bf215546Sopenharmony_ci * \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities
326bf215546Sopenharmony_ci */
327bf215546Sopenharmony_ci/*@{*/
328bf215546Sopenharmony_ci#define __DRI_FENCE_CAP_NATIVE_FD 1
329bf215546Sopenharmony_ci/*@}*/
330bf215546Sopenharmony_ci
331bf215546Sopenharmony_cistruct __DRI2fenceExtensionRec {
332bf215546Sopenharmony_ci   __DRIextension base;
333bf215546Sopenharmony_ci
334bf215546Sopenharmony_ci   /**
335bf215546Sopenharmony_ci    * Create and insert a fence into the command stream of the context.
336bf215546Sopenharmony_ci    */
337bf215546Sopenharmony_ci   void *(*create_fence)(__DRIcontext *ctx);
338bf215546Sopenharmony_ci
339bf215546Sopenharmony_ci   /**
340bf215546Sopenharmony_ci    * Get a fence associated with the OpenCL event object.
341bf215546Sopenharmony_ci    * This can be NULL, meaning that OpenCL interoperability is not supported.
342bf215546Sopenharmony_ci    */
343bf215546Sopenharmony_ci   void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event);
344bf215546Sopenharmony_ci
345bf215546Sopenharmony_ci   /**
346bf215546Sopenharmony_ci    * Destroy a fence.
347bf215546Sopenharmony_ci    */
348bf215546Sopenharmony_ci   void (*destroy_fence)(__DRIscreen *screen, void *fence);
349bf215546Sopenharmony_ci
350bf215546Sopenharmony_ci   /**
351bf215546Sopenharmony_ci    * This function waits and doesn't return until the fence is signalled
352bf215546Sopenharmony_ci    * or the timeout expires. It returns true if the fence has been signaled.
353bf215546Sopenharmony_ci    *
354bf215546Sopenharmony_ci    * \param ctx     the context where commands are flushed
355bf215546Sopenharmony_ci    * \param fence   the fence
356bf215546Sopenharmony_ci    * \param flags   a combination of __DRI2_FENCE_FLAG_xxx flags
357bf215546Sopenharmony_ci    * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE
358bf215546Sopenharmony_ci    */
359bf215546Sopenharmony_ci   unsigned char (*client_wait_sync)(__DRIcontext *ctx, void *fence,
360bf215546Sopenharmony_ci                                     unsigned flags, uint64_t timeout);
361bf215546Sopenharmony_ci
362bf215546Sopenharmony_ci   /**
363bf215546Sopenharmony_ci    * This function enqueues a wait command into the command stream of
364bf215546Sopenharmony_ci    * the context and then returns. When the execution reaches the wait
365bf215546Sopenharmony_ci    * command, no further execution will be done in the context until
366bf215546Sopenharmony_ci    * the fence is signaled. This is a no-op if the device doesn't support
367bf215546Sopenharmony_ci    * parallel execution of contexts.
368bf215546Sopenharmony_ci    *
369bf215546Sopenharmony_ci    * \param ctx     the context where the waiting is done
370bf215546Sopenharmony_ci    * \param fence   the fence
371bf215546Sopenharmony_ci    * \param flags   a combination of __DRI2_FENCE_FLAG_xxx flags that make
372bf215546Sopenharmony_ci    *                sense with this function (right now there are none)
373bf215546Sopenharmony_ci    */
374bf215546Sopenharmony_ci   void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags);
375bf215546Sopenharmony_ci
376bf215546Sopenharmony_ci   /**
377bf215546Sopenharmony_ci    * Query for general capabilities of the driver that concern fences.
378bf215546Sopenharmony_ci    * Returns a bitmask of __DRI_FENCE_CAP_x
379bf215546Sopenharmony_ci    *
380bf215546Sopenharmony_ci    * \since 2
381bf215546Sopenharmony_ci    */
382bf215546Sopenharmony_ci   unsigned (*get_capabilities)(__DRIscreen *screen);
383bf215546Sopenharmony_ci
384bf215546Sopenharmony_ci   /**
385bf215546Sopenharmony_ci    * Create an fd (file descriptor) associated fence.  If the fence fd
386bf215546Sopenharmony_ci    * is -1, this behaves similarly to create_fence() except that when
387bf215546Sopenharmony_ci    * rendering is flushed the driver creates a fence fd.  Otherwise,
388bf215546Sopenharmony_ci    * the driver wraps an existing fence fd.
389bf215546Sopenharmony_ci    *
390bf215546Sopenharmony_ci    * This is used to implement the EGL_ANDROID_native_fence_sync extension.
391bf215546Sopenharmony_ci    *
392bf215546Sopenharmony_ci    * \since 2
393bf215546Sopenharmony_ci    *
394bf215546Sopenharmony_ci    * \param ctx     the context associated with the fence
395bf215546Sopenharmony_ci    * \param fd      the fence fd or -1
396bf215546Sopenharmony_ci    */
397bf215546Sopenharmony_ci   void *(*create_fence_fd)(__DRIcontext *ctx, int fd);
398bf215546Sopenharmony_ci
399bf215546Sopenharmony_ci   /**
400bf215546Sopenharmony_ci    * For fences created with create_fence_fd(), after rendering is flushed,
401bf215546Sopenharmony_ci    * this retrieves the native fence fd.  Caller takes ownership of the
402bf215546Sopenharmony_ci    * fd and will close() it when it is no longer needed.
403bf215546Sopenharmony_ci    *
404bf215546Sopenharmony_ci    * \since 2
405bf215546Sopenharmony_ci    *
406bf215546Sopenharmony_ci    * \param screen  the screen associated with the fence
407bf215546Sopenharmony_ci    * \param fence   the fence
408bf215546Sopenharmony_ci    */
409bf215546Sopenharmony_ci   int (*get_fence_fd)(__DRIscreen *screen, void *fence);
410bf215546Sopenharmony_ci};
411bf215546Sopenharmony_ci
412bf215546Sopenharmony_ci
413bf215546Sopenharmony_ci/**
414bf215546Sopenharmony_ci * Extension for API interop.
415bf215546Sopenharmony_ci * See GL/mesa_glinterop.h.
416bf215546Sopenharmony_ci */
417bf215546Sopenharmony_ci
418bf215546Sopenharmony_ci#define __DRI2_INTEROP "DRI2_Interop"
419bf215546Sopenharmony_ci#define __DRI2_INTEROP_VERSION 1
420bf215546Sopenharmony_ci
421bf215546Sopenharmony_cistruct mesa_glinterop_device_info;
422bf215546Sopenharmony_cistruct mesa_glinterop_export_in;
423bf215546Sopenharmony_cistruct mesa_glinterop_export_out;
424bf215546Sopenharmony_ci
425bf215546Sopenharmony_cistruct __DRI2interopExtensionRec {
426bf215546Sopenharmony_ci   __DRIextension base;
427bf215546Sopenharmony_ci
428bf215546Sopenharmony_ci   /** Same as MesaGLInterop*QueryDeviceInfo. */
429bf215546Sopenharmony_ci   int (*query_device_info)(__DRIcontext *ctx,
430bf215546Sopenharmony_ci                            struct mesa_glinterop_device_info *out);
431bf215546Sopenharmony_ci
432bf215546Sopenharmony_ci   /** Same as MesaGLInterop*ExportObject. */
433bf215546Sopenharmony_ci   int (*export_object)(__DRIcontext *ctx,
434bf215546Sopenharmony_ci                        struct mesa_glinterop_export_in *in,
435bf215546Sopenharmony_ci                        struct mesa_glinterop_export_out *out);
436bf215546Sopenharmony_ci};
437bf215546Sopenharmony_ci
438bf215546Sopenharmony_ci
439bf215546Sopenharmony_ci/**
440bf215546Sopenharmony_ci * Extension for limiting window system back buffer rendering to user-defined
441bf215546Sopenharmony_ci * scissor region.
442bf215546Sopenharmony_ci */
443bf215546Sopenharmony_ci
444bf215546Sopenharmony_ci#define __DRI2_BUFFER_DAMAGE "DRI2_BufferDamage"
445bf215546Sopenharmony_ci#define __DRI2_BUFFER_DAMAGE_VERSION 1
446bf215546Sopenharmony_ci
447bf215546Sopenharmony_cistruct __DRI2bufferDamageExtensionRec {
448bf215546Sopenharmony_ci   __DRIextension base;
449bf215546Sopenharmony_ci
450bf215546Sopenharmony_ci   /**
451bf215546Sopenharmony_ci    * Provides an array of rectangles representing an overriding scissor region
452bf215546Sopenharmony_ci    * for rendering operations performed to the specified drawable. These
453bf215546Sopenharmony_ci    * rectangles do not replace client API scissor regions or draw
454bf215546Sopenharmony_ci    * co-ordinates, but instead inform the driver of the overall bounds of all
455bf215546Sopenharmony_ci    * operations which will be issued before the next flush.
456bf215546Sopenharmony_ci    *
457bf215546Sopenharmony_ci    * Any rendering operations writing pixels outside this region to the
458bf215546Sopenharmony_ci    * drawable will have an undefined effect on the entire drawable.
459bf215546Sopenharmony_ci    *
460bf215546Sopenharmony_ci    * This entrypoint may only be called after the drawable has either been
461bf215546Sopenharmony_ci    * newly created or flushed, and before any rendering operations which write
462bf215546Sopenharmony_ci    * pixels to the drawable. Calling this entrypoint at any other time will
463bf215546Sopenharmony_ci    * have an undefined effect on the entire drawable.
464bf215546Sopenharmony_ci    *
465bf215546Sopenharmony_ci    * Calling this entrypoint with @nrects 0 and @rects NULL will reset the
466bf215546Sopenharmony_ci    * region to the buffer's full size. This entrypoint may be called once to
467bf215546Sopenharmony_ci    * reset the region, followed by a second call with a populated region,
468bf215546Sopenharmony_ci    * before a rendering call is made.
469bf215546Sopenharmony_ci    *
470bf215546Sopenharmony_ci    * Used to implement EGL_KHR_partial_update.
471bf215546Sopenharmony_ci    *
472bf215546Sopenharmony_ci    * \param drawable affected drawable
473bf215546Sopenharmony_ci    * \param nrects   number of rectangles provided
474bf215546Sopenharmony_ci    * \param rects    the array of rectangles, lower-left origin
475bf215546Sopenharmony_ci    */
476bf215546Sopenharmony_ci   void (*set_damage_region)(__DRIdrawable *drawable, unsigned int nrects,
477bf215546Sopenharmony_ci                             int *rects);
478bf215546Sopenharmony_ci};
479bf215546Sopenharmony_ci
480bf215546Sopenharmony_ci/*@}*/
481bf215546Sopenharmony_ci
482bf215546Sopenharmony_ci/**
483bf215546Sopenharmony_ci * The following extensions describe loader features that the DRI
484bf215546Sopenharmony_ci * driver can make use of.  Some of these are mandatory, such as the
485bf215546Sopenharmony_ci * getDrawableInfo extension for DRI and the DRI Loader extensions for
486bf215546Sopenharmony_ci * DRI2, while others are optional, and if present allow the driver to
487bf215546Sopenharmony_ci * expose certain features.  The loader pass in a NULL terminated
488bf215546Sopenharmony_ci * array of these extensions to the driver in the createNewScreen
489bf215546Sopenharmony_ci * constructor.
490bf215546Sopenharmony_ci */
491bf215546Sopenharmony_ci
492bf215546Sopenharmony_citypedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
493bf215546Sopenharmony_citypedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
494bf215546Sopenharmony_citypedef struct __DRIdamageExtensionRec __DRIdamageExtension;
495bf215546Sopenharmony_citypedef struct __DRIloaderExtensionRec __DRIloaderExtension;
496bf215546Sopenharmony_citypedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
497bf215546Sopenharmony_ci
498bf215546Sopenharmony_ci/**
499bf215546Sopenharmony_ci * Callback to get system time for media stream counter extensions.
500bf215546Sopenharmony_ci */
501bf215546Sopenharmony_ci#define __DRI_SYSTEM_TIME "DRI_SystemTime"
502bf215546Sopenharmony_ci#define __DRI_SYSTEM_TIME_VERSION 1
503bf215546Sopenharmony_cistruct __DRIsystemTimeExtensionRec {
504bf215546Sopenharmony_ci    __DRIextension base;
505bf215546Sopenharmony_ci
506bf215546Sopenharmony_ci    /**
507bf215546Sopenharmony_ci     * Get the 64-bit unadjusted system time (UST).
508bf215546Sopenharmony_ci     */
509bf215546Sopenharmony_ci    int (*getUST)(int64_t * ust);
510bf215546Sopenharmony_ci
511bf215546Sopenharmony_ci    /**
512bf215546Sopenharmony_ci     * Get the media stream counter (MSC) rate.
513bf215546Sopenharmony_ci     *
514bf215546Sopenharmony_ci     * Matching the definition in GLX_OML_sync_control, this function returns
515bf215546Sopenharmony_ci     * the rate of the "media stream counter".  In practical terms, this is
516bf215546Sopenharmony_ci     * the frame refresh rate of the display.
517bf215546Sopenharmony_ci     */
518bf215546Sopenharmony_ci    unsigned char (*getMSCRate)(__DRIdrawable *draw,
519bf215546Sopenharmony_ci			    int32_t * numerator, int32_t * denominator,
520bf215546Sopenharmony_ci			    void *loaderPrivate);
521bf215546Sopenharmony_ci};
522bf215546Sopenharmony_ci
523bf215546Sopenharmony_ci#define __DRI_SWRAST_IMAGE_OP_DRAW	1
524bf215546Sopenharmony_ci#define __DRI_SWRAST_IMAGE_OP_CLEAR	2
525bf215546Sopenharmony_ci#define __DRI_SWRAST_IMAGE_OP_SWAP	3
526bf215546Sopenharmony_ci
527bf215546Sopenharmony_ci/**
528bf215546Sopenharmony_ci * SWRast Loader extension.
529bf215546Sopenharmony_ci */
530bf215546Sopenharmony_ci#define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
531bf215546Sopenharmony_ci#define __DRI_SWRAST_LOADER_VERSION 6
532bf215546Sopenharmony_cistruct __DRIswrastLoaderExtensionRec {
533bf215546Sopenharmony_ci    __DRIextension base;
534bf215546Sopenharmony_ci
535bf215546Sopenharmony_ci    /*
536bf215546Sopenharmony_ci     * Drawable position and size
537bf215546Sopenharmony_ci     */
538bf215546Sopenharmony_ci    void (*getDrawableInfo)(__DRIdrawable *drawable,
539bf215546Sopenharmony_ci			    int *x, int *y, int *width, int *height,
540bf215546Sopenharmony_ci			    void *loaderPrivate);
541bf215546Sopenharmony_ci
542bf215546Sopenharmony_ci    /**
543bf215546Sopenharmony_ci     * Put image to drawable
544bf215546Sopenharmony_ci     */
545bf215546Sopenharmony_ci    void (*putImage)(__DRIdrawable *drawable, int op,
546bf215546Sopenharmony_ci		     int x, int y, int width, int height,
547bf215546Sopenharmony_ci		     char *data, void *loaderPrivate);
548bf215546Sopenharmony_ci
549bf215546Sopenharmony_ci    /**
550bf215546Sopenharmony_ci     * Get image from readable
551bf215546Sopenharmony_ci     */
552bf215546Sopenharmony_ci    void (*getImage)(__DRIdrawable *readable,
553bf215546Sopenharmony_ci		     int x, int y, int width, int height,
554bf215546Sopenharmony_ci		     char *data, void *loaderPrivate);
555bf215546Sopenharmony_ci
556bf215546Sopenharmony_ci    /**
557bf215546Sopenharmony_ci     * Put image to drawable
558bf215546Sopenharmony_ci     *
559bf215546Sopenharmony_ci     * \since 2
560bf215546Sopenharmony_ci     */
561bf215546Sopenharmony_ci    void (*putImage2)(__DRIdrawable *drawable, int op,
562bf215546Sopenharmony_ci                      int x, int y, int width, int height, int stride,
563bf215546Sopenharmony_ci                      char *data, void *loaderPrivate);
564bf215546Sopenharmony_ci
565bf215546Sopenharmony_ci   /**
566bf215546Sopenharmony_ci     * Put image to drawable
567bf215546Sopenharmony_ci     *
568bf215546Sopenharmony_ci     * \since 3
569bf215546Sopenharmony_ci     */
570bf215546Sopenharmony_ci   void (*getImage2)(__DRIdrawable *readable,
571bf215546Sopenharmony_ci		     int x, int y, int width, int height, int stride,
572bf215546Sopenharmony_ci		     char *data, void *loaderPrivate);
573bf215546Sopenharmony_ci
574bf215546Sopenharmony_ci    /**
575bf215546Sopenharmony_ci     * Put shm image to drawable
576bf215546Sopenharmony_ci     *
577bf215546Sopenharmony_ci     * \since 4
578bf215546Sopenharmony_ci     */
579bf215546Sopenharmony_ci    void (*putImageShm)(__DRIdrawable *drawable, int op,
580bf215546Sopenharmony_ci                        int x, int y, int width, int height, int stride,
581bf215546Sopenharmony_ci                        int shmid, char *shmaddr, unsigned offset,
582bf215546Sopenharmony_ci                        void *loaderPrivate);
583bf215546Sopenharmony_ci    /**
584bf215546Sopenharmony_ci     * Get shm image from readable
585bf215546Sopenharmony_ci     *
586bf215546Sopenharmony_ci     * \since 4
587bf215546Sopenharmony_ci     */
588bf215546Sopenharmony_ci    void (*getImageShm)(__DRIdrawable *readable,
589bf215546Sopenharmony_ci                        int x, int y, int width, int height,
590bf215546Sopenharmony_ci                        int shmid, void *loaderPrivate);
591bf215546Sopenharmony_ci
592bf215546Sopenharmony_ci   /**
593bf215546Sopenharmony_ci     * Put shm image to drawable (v2)
594bf215546Sopenharmony_ci     *
595bf215546Sopenharmony_ci     * The original version fixes srcx/y to 0, and expected
596bf215546Sopenharmony_ci     * the offset to be adjusted. This version allows src x,y
597bf215546Sopenharmony_ci     * to not be included in the offset. This is needed to
598bf215546Sopenharmony_ci     * avoid certain overflow checks in the X server, that
599bf215546Sopenharmony_ci     * result in lost rendering.
600bf215546Sopenharmony_ci     *
601bf215546Sopenharmony_ci     * \since 5
602bf215546Sopenharmony_ci     */
603bf215546Sopenharmony_ci    void (*putImageShm2)(__DRIdrawable *drawable, int op,
604bf215546Sopenharmony_ci                         int x, int y,
605bf215546Sopenharmony_ci                         int width, int height, int stride,
606bf215546Sopenharmony_ci                         int shmid, char *shmaddr, unsigned offset,
607bf215546Sopenharmony_ci                         void *loaderPrivate);
608bf215546Sopenharmony_ci
609bf215546Sopenharmony_ci    /**
610bf215546Sopenharmony_ci     * get shm image to drawable (v2)
611bf215546Sopenharmony_ci     *
612bf215546Sopenharmony_ci     * There are some cases where GLX can't use SHM, but DRI
613bf215546Sopenharmony_ci     * still tries, we need to get a return type for when to
614bf215546Sopenharmony_ci     * fallback to the non-shm path.
615bf215546Sopenharmony_ci     *
616bf215546Sopenharmony_ci     * \since 6
617bf215546Sopenharmony_ci     */
618bf215546Sopenharmony_ci    unsigned char (*getImageShm2)(__DRIdrawable *readable,
619bf215546Sopenharmony_ci                                  int x, int y, int width, int height,
620bf215546Sopenharmony_ci                                  int shmid, void *loaderPrivate);
621bf215546Sopenharmony_ci};
622bf215546Sopenharmony_ci
623bf215546Sopenharmony_ci/**
624bf215546Sopenharmony_ci * Invalidate loader extension.  The presence of this extension
625bf215546Sopenharmony_ci * indicates to the DRI driver that the loader will call invalidate in
626bf215546Sopenharmony_ci * the __DRI2_FLUSH extension, whenever the needs to query for new
627bf215546Sopenharmony_ci * buffers.  This means that the DRI driver can drop the polling in
628bf215546Sopenharmony_ci * glViewport().
629bf215546Sopenharmony_ci *
630bf215546Sopenharmony_ci * The extension doesn't provide any functionality, it's only use to
631bf215546Sopenharmony_ci * indicate to the driver that it can use the new semantics.  A DRI
632bf215546Sopenharmony_ci * driver can use this to switch between the different semantics or
633bf215546Sopenharmony_ci * just refuse to initialize if this extension isn't present.
634bf215546Sopenharmony_ci */
635bf215546Sopenharmony_ci#define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
636bf215546Sopenharmony_ci#define __DRI_USE_INVALIDATE_VERSION 1
637bf215546Sopenharmony_ci
638bf215546Sopenharmony_citypedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
639bf215546Sopenharmony_cistruct __DRIuseInvalidateExtensionRec {
640bf215546Sopenharmony_ci   __DRIextension base;
641bf215546Sopenharmony_ci};
642bf215546Sopenharmony_ci
643bf215546Sopenharmony_ci/**
644bf215546Sopenharmony_ci * The remaining extensions describe driver extensions, immediately
645bf215546Sopenharmony_ci * available interfaces provided by the driver.  To start using the
646bf215546Sopenharmony_ci * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
647bf215546Sopenharmony_ci * the extension you need in the array.
648bf215546Sopenharmony_ci */
649bf215546Sopenharmony_ci#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
650bf215546Sopenharmony_ci
651bf215546Sopenharmony_ci/**
652bf215546Sopenharmony_ci * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
653bf215546Sopenharmony_ci * suffixed by "_drivername", allowing multiple drivers to be built into one
654bf215546Sopenharmony_ci * library, and also giving the driver the chance to return a variable driver
655bf215546Sopenharmony_ci * extensions struct depending on the driver name being loaded or any other
656bf215546Sopenharmony_ci * system state.
657bf215546Sopenharmony_ci *
658bf215546Sopenharmony_ci * The function prototype is:
659bf215546Sopenharmony_ci *
660bf215546Sopenharmony_ci * const __DRIextension **__driDriverGetExtensions_drivername(void);
661bf215546Sopenharmony_ci */
662bf215546Sopenharmony_ci#define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
663bf215546Sopenharmony_ci
664bf215546Sopenharmony_ci/**
665bf215546Sopenharmony_ci * Tokens for __DRIconfig attribs.  A number of attributes defined by
666bf215546Sopenharmony_ci * GLX or EGL standards are not in the table, as they must be provided
667bf215546Sopenharmony_ci * by the loader.  For example, FBConfig ID or visual ID, drawable type.
668bf215546Sopenharmony_ci */
669bf215546Sopenharmony_ci
670bf215546Sopenharmony_ci#define __DRI_ATTRIB_BUFFER_SIZE		 1
671bf215546Sopenharmony_ci#define __DRI_ATTRIB_LEVEL			 2
672bf215546Sopenharmony_ci#define __DRI_ATTRIB_RED_SIZE			 3
673bf215546Sopenharmony_ci#define __DRI_ATTRIB_GREEN_SIZE			 4
674bf215546Sopenharmony_ci#define __DRI_ATTRIB_BLUE_SIZE			 5
675bf215546Sopenharmony_ci#define __DRI_ATTRIB_LUMINANCE_SIZE		 6
676bf215546Sopenharmony_ci#define __DRI_ATTRIB_ALPHA_SIZE			 7
677bf215546Sopenharmony_ci#define __DRI_ATTRIB_ALPHA_MASK_SIZE		 8
678bf215546Sopenharmony_ci#define __DRI_ATTRIB_DEPTH_SIZE			 9
679bf215546Sopenharmony_ci#define __DRI_ATTRIB_STENCIL_SIZE		10
680bf215546Sopenharmony_ci#define __DRI_ATTRIB_ACCUM_RED_SIZE		11
681bf215546Sopenharmony_ci#define __DRI_ATTRIB_ACCUM_GREEN_SIZE		12
682bf215546Sopenharmony_ci#define __DRI_ATTRIB_ACCUM_BLUE_SIZE		13
683bf215546Sopenharmony_ci#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE		14
684bf215546Sopenharmony_ci#define __DRI_ATTRIB_SAMPLE_BUFFERS		15
685bf215546Sopenharmony_ci#define __DRI_ATTRIB_SAMPLES			16
686bf215546Sopenharmony_ci#define __DRI_ATTRIB_RENDER_TYPE		17
687bf215546Sopenharmony_ci#define __DRI_ATTRIB_CONFIG_CAVEAT		18
688bf215546Sopenharmony_ci#define __DRI_ATTRIB_CONFORMANT			19
689bf215546Sopenharmony_ci#define __DRI_ATTRIB_DOUBLE_BUFFER		20
690bf215546Sopenharmony_ci#define __DRI_ATTRIB_STEREO			21
691bf215546Sopenharmony_ci#define __DRI_ATTRIB_AUX_BUFFERS		22
692bf215546Sopenharmony_ci#define __DRI_ATTRIB_TRANSPARENT_TYPE		23
693bf215546Sopenharmony_ci#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE	24
694bf215546Sopenharmony_ci#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE	25
695bf215546Sopenharmony_ci#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE	26
696bf215546Sopenharmony_ci#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE	27
697bf215546Sopenharmony_ci#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE	28
698bf215546Sopenharmony_ci#define __DRI_ATTRIB_FLOAT_MODE			29
699bf215546Sopenharmony_ci#define __DRI_ATTRIB_RED_MASK			30
700bf215546Sopenharmony_ci#define __DRI_ATTRIB_GREEN_MASK			31
701bf215546Sopenharmony_ci#define __DRI_ATTRIB_BLUE_MASK			32
702bf215546Sopenharmony_ci#define __DRI_ATTRIB_ALPHA_MASK			33
703bf215546Sopenharmony_ci#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH		34
704bf215546Sopenharmony_ci#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT		35
705bf215546Sopenharmony_ci#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS		36
706bf215546Sopenharmony_ci#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH	37
707bf215546Sopenharmony_ci#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT	38
708bf215546Sopenharmony_ci#define __DRI_ATTRIB_VISUAL_SELECT_GROUP	39
709bf215546Sopenharmony_ci#define __DRI_ATTRIB_SWAP_METHOD		40
710bf215546Sopenharmony_ci#define __DRI_ATTRIB_MAX_SWAP_INTERVAL		41
711bf215546Sopenharmony_ci#define __DRI_ATTRIB_MIN_SWAP_INTERVAL		42
712bf215546Sopenharmony_ci#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB	43
713bf215546Sopenharmony_ci#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA	44
714bf215546Sopenharmony_ci#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE	45
715bf215546Sopenharmony_ci#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS	46
716bf215546Sopenharmony_ci#define __DRI_ATTRIB_YINVERTED			47
717bf215546Sopenharmony_ci#define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE	48
718bf215546Sopenharmony_ci#define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER	49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */
719bf215546Sopenharmony_ci#define __DRI_ATTRIB_RED_SHIFT			50
720bf215546Sopenharmony_ci#define __DRI_ATTRIB_GREEN_SHIFT		51
721bf215546Sopenharmony_ci#define __DRI_ATTRIB_BLUE_SHIFT			52
722bf215546Sopenharmony_ci#define __DRI_ATTRIB_ALPHA_SHIFT		53
723bf215546Sopenharmony_ci#define __DRI_ATTRIB_MAX			54
724bf215546Sopenharmony_ci
725bf215546Sopenharmony_ci/* __DRI_ATTRIB_RENDER_TYPE */
726bf215546Sopenharmony_ci#define __DRI_ATTRIB_RGBA_BIT			0x01
727bf215546Sopenharmony_ci#define __DRI_ATTRIB_COLOR_INDEX_BIT		0x02
728bf215546Sopenharmony_ci#define __DRI_ATTRIB_LUMINANCE_BIT		0x04
729bf215546Sopenharmony_ci#define __DRI_ATTRIB_FLOAT_BIT			0x08
730bf215546Sopenharmony_ci#define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT		0x10
731bf215546Sopenharmony_ci
732bf215546Sopenharmony_ci/* __DRI_ATTRIB_CONFIG_CAVEAT */
733bf215546Sopenharmony_ci#define __DRI_ATTRIB_SLOW_BIT			0x01
734bf215546Sopenharmony_ci#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG	0x02
735bf215546Sopenharmony_ci
736bf215546Sopenharmony_ci/* __DRI_ATTRIB_TRANSPARENT_TYPE */
737bf215546Sopenharmony_ci#define __DRI_ATTRIB_TRANSPARENT_RGB		0x00
738bf215546Sopenharmony_ci#define __DRI_ATTRIB_TRANSPARENT_INDEX		0x01
739bf215546Sopenharmony_ci
740bf215546Sopenharmony_ci/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS	 */
741bf215546Sopenharmony_ci#define __DRI_ATTRIB_TEXTURE_1D_BIT		0x01
742bf215546Sopenharmony_ci#define __DRI_ATTRIB_TEXTURE_2D_BIT		0x02
743bf215546Sopenharmony_ci#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT	0x04
744bf215546Sopenharmony_ci
745bf215546Sopenharmony_ci/* __DRI_ATTRIB_SWAP_METHOD */
746bf215546Sopenharmony_ci/* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define
747bf215546Sopenharmony_ci * the same tokens as GLX. This is because old and current X servers will
748bf215546Sopenharmony_ci * transmit the driconf value grabbed from the AIGLX driver untranslated as
749bf215546Sopenharmony_ci * the GLX fbconfig value. __DRI_ATTRIB_SWAP_NONE is only used by dri drivers
750bf215546Sopenharmony_ci * to signal to the dri core that the driconfig is single-buffer.
751bf215546Sopenharmony_ci */
752bf215546Sopenharmony_ci#define __DRI_ATTRIB_SWAP_NONE                  0x0000
753bf215546Sopenharmony_ci#define __DRI_ATTRIB_SWAP_EXCHANGE              0x8061
754bf215546Sopenharmony_ci#define __DRI_ATTRIB_SWAP_COPY                  0x8062
755bf215546Sopenharmony_ci#define __DRI_ATTRIB_SWAP_UNDEFINED             0x8063
756bf215546Sopenharmony_ci
757bf215546Sopenharmony_ci/**
758bf215546Sopenharmony_ci * This extension defines the core DRI functionality.
759bf215546Sopenharmony_ci *
760bf215546Sopenharmony_ci * Version >= 2 indicates that getConfigAttrib with __DRI_ATTRIB_SWAP_METHOD
761bf215546Sopenharmony_ci * returns a reliable value.
762bf215546Sopenharmony_ci */
763bf215546Sopenharmony_ci#define __DRI_CORE "DRI_Core"
764bf215546Sopenharmony_ci#define __DRI_CORE_VERSION 2
765bf215546Sopenharmony_ci
766bf215546Sopenharmony_cistruct __DRIcoreExtensionRec {
767bf215546Sopenharmony_ci    __DRIextension base;
768bf215546Sopenharmony_ci
769bf215546Sopenharmony_ci    __DRIscreen *(*createNewScreen)(int screen, int fd,
770bf215546Sopenharmony_ci				    unsigned int sarea_handle,
771bf215546Sopenharmony_ci				    const __DRIextension **extensions,
772bf215546Sopenharmony_ci				    const __DRIconfig ***driverConfigs,
773bf215546Sopenharmony_ci				    void *loaderPrivate);
774bf215546Sopenharmony_ci
775bf215546Sopenharmony_ci    void (*destroyScreen)(__DRIscreen *screen);
776bf215546Sopenharmony_ci
777bf215546Sopenharmony_ci    const __DRIextension **(*getExtensions)(__DRIscreen *screen);
778bf215546Sopenharmony_ci
779bf215546Sopenharmony_ci    int (*getConfigAttrib)(const __DRIconfig *config,
780bf215546Sopenharmony_ci			   unsigned int attrib,
781bf215546Sopenharmony_ci			   unsigned int *value);
782bf215546Sopenharmony_ci
783bf215546Sopenharmony_ci    int (*indexConfigAttrib)(const __DRIconfig *config, int index,
784bf215546Sopenharmony_ci			     unsigned int *attrib, unsigned int *value);
785bf215546Sopenharmony_ci
786bf215546Sopenharmony_ci    __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
787bf215546Sopenharmony_ci					const __DRIconfig *config,
788bf215546Sopenharmony_ci					unsigned int drawable_id,
789bf215546Sopenharmony_ci					unsigned int head,
790bf215546Sopenharmony_ci					void *loaderPrivate);
791bf215546Sopenharmony_ci
792bf215546Sopenharmony_ci    void (*destroyDrawable)(__DRIdrawable *drawable);
793bf215546Sopenharmony_ci
794bf215546Sopenharmony_ci    void (*swapBuffers)(__DRIdrawable *drawable);
795bf215546Sopenharmony_ci
796bf215546Sopenharmony_ci    __DRIcontext *(*createNewContext)(__DRIscreen *screen,
797bf215546Sopenharmony_ci				      const __DRIconfig *config,
798bf215546Sopenharmony_ci				      __DRIcontext *shared,
799bf215546Sopenharmony_ci				      void *loaderPrivate);
800bf215546Sopenharmony_ci
801bf215546Sopenharmony_ci    int (*copyContext)(__DRIcontext *dest,
802bf215546Sopenharmony_ci		       __DRIcontext *src,
803bf215546Sopenharmony_ci		       unsigned long mask);
804bf215546Sopenharmony_ci
805bf215546Sopenharmony_ci    void (*destroyContext)(__DRIcontext *context);
806bf215546Sopenharmony_ci
807bf215546Sopenharmony_ci    int (*bindContext)(__DRIcontext *ctx,
808bf215546Sopenharmony_ci		       __DRIdrawable *pdraw,
809bf215546Sopenharmony_ci		       __DRIdrawable *pread);
810bf215546Sopenharmony_ci
811bf215546Sopenharmony_ci    int (*unbindContext)(__DRIcontext *ctx);
812bf215546Sopenharmony_ci};
813bf215546Sopenharmony_ci
814bf215546Sopenharmony_ci/**
815bf215546Sopenharmony_ci * Stored version of some component (i.e., server-side DRI module, kernel-side
816bf215546Sopenharmony_ci * DRM, etc.).
817bf215546Sopenharmony_ci *
818bf215546Sopenharmony_ci * \todo
819bf215546Sopenharmony_ci * There are several data structures that explicitly store a major version,
820bf215546Sopenharmony_ci * minor version, and patch level.  These structures should be modified to
821bf215546Sopenharmony_ci * have a \c __DRIversionRec instead.
822bf215546Sopenharmony_ci */
823bf215546Sopenharmony_cistruct __DRIversionRec {
824bf215546Sopenharmony_ci    int    major;        /**< Major version number. */
825bf215546Sopenharmony_ci    int    minor;        /**< Minor version number. */
826bf215546Sopenharmony_ci    int    patch;        /**< Patch-level. */
827bf215546Sopenharmony_ci};
828bf215546Sopenharmony_ci
829bf215546Sopenharmony_ci/**
830bf215546Sopenharmony_ci * Framebuffer information record.  Used by libGL to communicate information
831bf215546Sopenharmony_ci * about the framebuffer to the driver's \c __driCreateNewScreen function.
832bf215546Sopenharmony_ci *
833bf215546Sopenharmony_ci * In XFree86, most of this information is derrived from data returned by
834bf215546Sopenharmony_ci * calling \c XF86DRIGetDeviceInfo.
835bf215546Sopenharmony_ci *
836bf215546Sopenharmony_ci * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
837bf215546Sopenharmony_ci *     __driUtilCreateNewScreen CallCreateNewScreen
838bf215546Sopenharmony_ci *
839bf215546Sopenharmony_ci * \bug This structure could be better named.
840bf215546Sopenharmony_ci */
841bf215546Sopenharmony_cistruct __DRIframebufferRec {
842bf215546Sopenharmony_ci    unsigned char *base;    /**< Framebuffer base address in the CPU's
843bf215546Sopenharmony_ci			     * address space.  This value is calculated by
844bf215546Sopenharmony_ci			     * calling \c drmMap on the framebuffer handle
845bf215546Sopenharmony_ci			     * returned by \c XF86DRIGetDeviceInfo (or a
846bf215546Sopenharmony_ci			     * similar function).
847bf215546Sopenharmony_ci			     */
848bf215546Sopenharmony_ci    int size;               /**< Framebuffer size, in bytes. */
849bf215546Sopenharmony_ci    int stride;             /**< Number of bytes from one line to the next. */
850bf215546Sopenharmony_ci    int width;              /**< Pixel width of the framebuffer. */
851bf215546Sopenharmony_ci    int height;             /**< Pixel height of the framebuffer. */
852bf215546Sopenharmony_ci    int dev_priv_size;      /**< Size of the driver's dev-priv structure. */
853bf215546Sopenharmony_ci    void *dev_priv;         /**< Pointer to the driver's dev-priv structure. */
854bf215546Sopenharmony_ci};
855bf215546Sopenharmony_ci
856bf215546Sopenharmony_ci
857bf215546Sopenharmony_ci/**
858bf215546Sopenharmony_ci * This extension provides alternative screen, drawable and context
859bf215546Sopenharmony_ci * constructors for swrast DRI functionality.  This is used in
860bf215546Sopenharmony_ci * conjunction with the core extension.
861bf215546Sopenharmony_ci */
862bf215546Sopenharmony_ci#define __DRI_SWRAST "DRI_SWRast"
863bf215546Sopenharmony_ci#define __DRI_SWRAST_VERSION 4
864bf215546Sopenharmony_ci
865bf215546Sopenharmony_cistruct __DRIswrastExtensionRec {
866bf215546Sopenharmony_ci    __DRIextension base;
867bf215546Sopenharmony_ci
868bf215546Sopenharmony_ci    __DRIscreen *(*createNewScreen)(int screen,
869bf215546Sopenharmony_ci				    const __DRIextension **extensions,
870bf215546Sopenharmony_ci				    const __DRIconfig ***driver_configs,
871bf215546Sopenharmony_ci				    void *loaderPrivate);
872bf215546Sopenharmony_ci
873bf215546Sopenharmony_ci    __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
874bf215546Sopenharmony_ci					const __DRIconfig *config,
875bf215546Sopenharmony_ci					void *loaderPrivate);
876bf215546Sopenharmony_ci
877bf215546Sopenharmony_ci   /* Since version 2 */
878bf215546Sopenharmony_ci   __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
879bf215546Sopenharmony_ci                                           int api,
880bf215546Sopenharmony_ci                                           const __DRIconfig *config,
881bf215546Sopenharmony_ci                                           __DRIcontext *shared,
882bf215546Sopenharmony_ci                                           void *data);
883bf215546Sopenharmony_ci
884bf215546Sopenharmony_ci   /**
885bf215546Sopenharmony_ci    * Create a context for a particular API with a set of attributes
886bf215546Sopenharmony_ci    *
887bf215546Sopenharmony_ci    * \since version 3
888bf215546Sopenharmony_ci    *
889bf215546Sopenharmony_ci    * \sa __DRIdri2ExtensionRec::createContextAttribs
890bf215546Sopenharmony_ci    */
891bf215546Sopenharmony_ci   __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
892bf215546Sopenharmony_ci					 int api,
893bf215546Sopenharmony_ci					 const __DRIconfig *config,
894bf215546Sopenharmony_ci					 __DRIcontext *shared,
895bf215546Sopenharmony_ci					 unsigned num_attribs,
896bf215546Sopenharmony_ci					 const uint32_t *attribs,
897bf215546Sopenharmony_ci					 unsigned *error,
898bf215546Sopenharmony_ci					 void *loaderPrivate);
899bf215546Sopenharmony_ci
900bf215546Sopenharmony_ci   /**
901bf215546Sopenharmony_ci    * createNewScreen() with the driver extensions passed in.
902bf215546Sopenharmony_ci    *
903bf215546Sopenharmony_ci    * \since version 4
904bf215546Sopenharmony_ci    */
905bf215546Sopenharmony_ci   __DRIscreen *(*createNewScreen2)(int screen,
906bf215546Sopenharmony_ci                                    const __DRIextension **loader_extensions,
907bf215546Sopenharmony_ci                                    const __DRIextension **driver_extensions,
908bf215546Sopenharmony_ci                                    const __DRIconfig ***driver_configs,
909bf215546Sopenharmony_ci                                    void *loaderPrivate);
910bf215546Sopenharmony_ci
911bf215546Sopenharmony_ci};
912bf215546Sopenharmony_ci
913bf215546Sopenharmony_ci/** Common DRI function definitions, shared among DRI2 and Image extensions
914bf215546Sopenharmony_ci */
915bf215546Sopenharmony_ci
916bf215546Sopenharmony_citypedef __DRIscreen *
917bf215546Sopenharmony_ci(*__DRIcreateNewScreen2Func)(int screen, int fd,
918bf215546Sopenharmony_ci                             const __DRIextension **extensions,
919bf215546Sopenharmony_ci                             const __DRIextension **driver_extensions,
920bf215546Sopenharmony_ci                             const __DRIconfig ***driver_configs,
921bf215546Sopenharmony_ci                             void *loaderPrivate);
922bf215546Sopenharmony_ci
923bf215546Sopenharmony_citypedef __DRIdrawable *
924bf215546Sopenharmony_ci(*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
925bf215546Sopenharmony_ci                              const __DRIconfig *config,
926bf215546Sopenharmony_ci                              void *loaderPrivate);
927bf215546Sopenharmony_ci
928bf215546Sopenharmony_citypedef __DRIcontext *
929bf215546Sopenharmony_ci(*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
930bf215546Sopenharmony_ci                                 int api,
931bf215546Sopenharmony_ci                                 const __DRIconfig *config,
932bf215546Sopenharmony_ci                                 __DRIcontext *shared,
933bf215546Sopenharmony_ci                                 unsigned num_attribs,
934bf215546Sopenharmony_ci                                 const uint32_t *attribs,
935bf215546Sopenharmony_ci                                 unsigned *error,
936bf215546Sopenharmony_ci                                 void *loaderPrivate);
937bf215546Sopenharmony_ci
938bf215546Sopenharmony_citypedef unsigned int
939bf215546Sopenharmony_ci(*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
940bf215546Sopenharmony_ci
941bf215546Sopenharmony_ci/**
942bf215546Sopenharmony_ci * DRI2 Loader extension.
943bf215546Sopenharmony_ci */
944bf215546Sopenharmony_ci#define __DRI_BUFFER_FRONT_LEFT		0
945bf215546Sopenharmony_ci#define __DRI_BUFFER_BACK_LEFT		1
946bf215546Sopenharmony_ci#define __DRI_BUFFER_FRONT_RIGHT	2
947bf215546Sopenharmony_ci#define __DRI_BUFFER_BACK_RIGHT		3
948bf215546Sopenharmony_ci#define __DRI_BUFFER_DEPTH		4
949bf215546Sopenharmony_ci#define __DRI_BUFFER_STENCIL		5
950bf215546Sopenharmony_ci#define __DRI_BUFFER_ACCUM		6
951bf215546Sopenharmony_ci#define __DRI_BUFFER_FAKE_FRONT_LEFT	7
952bf215546Sopenharmony_ci#define __DRI_BUFFER_FAKE_FRONT_RIGHT	8
953bf215546Sopenharmony_ci#define __DRI_BUFFER_DEPTH_STENCIL	9  /**< Only available with DRI2 1.1 */
954bf215546Sopenharmony_ci#define __DRI_BUFFER_HIZ		10
955bf215546Sopenharmony_ci
956bf215546Sopenharmony_ci/* Inofficial and for internal use. Increase when adding a new buffer token. */
957bf215546Sopenharmony_ci#define __DRI_BUFFER_COUNT		11
958bf215546Sopenharmony_ci
959bf215546Sopenharmony_cistruct __DRIbufferRec {
960bf215546Sopenharmony_ci    unsigned int attachment;
961bf215546Sopenharmony_ci    unsigned int name;
962bf215546Sopenharmony_ci    unsigned int pitch;
963bf215546Sopenharmony_ci    unsigned int cpp;
964bf215546Sopenharmony_ci    unsigned int flags;
965bf215546Sopenharmony_ci};
966bf215546Sopenharmony_ci
967bf215546Sopenharmony_ci#define __DRI_DRI2_LOADER "DRI_DRI2Loader"
968bf215546Sopenharmony_ci#define __DRI_DRI2_LOADER_VERSION 5
969bf215546Sopenharmony_ci
970bf215546Sopenharmony_cienum dri_loader_cap {
971bf215546Sopenharmony_ci   /* Whether the loader handles RGBA channel ordering correctly. If not,
972bf215546Sopenharmony_ci    * only BGRA ordering can be exposed.
973bf215546Sopenharmony_ci    */
974bf215546Sopenharmony_ci   DRI_LOADER_CAP_RGBA_ORDERING,
975bf215546Sopenharmony_ci   DRI_LOADER_CAP_FP16,
976bf215546Sopenharmony_ci};
977bf215546Sopenharmony_ci
978bf215546Sopenharmony_cistruct __DRIdri2LoaderExtensionRec {
979bf215546Sopenharmony_ci    __DRIextension base;
980bf215546Sopenharmony_ci
981bf215546Sopenharmony_ci    __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
982bf215546Sopenharmony_ci			       int *width, int *height,
983bf215546Sopenharmony_ci			       unsigned int *attachments, int count,
984bf215546Sopenharmony_ci			       int *out_count, void *loaderPrivate);
985bf215546Sopenharmony_ci
986bf215546Sopenharmony_ci    /**
987bf215546Sopenharmony_ci     * Flush pending front-buffer rendering
988bf215546Sopenharmony_ci     *
989bf215546Sopenharmony_ci     * Any rendering that has been performed to the
990bf215546Sopenharmony_ci     * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
991bf215546Sopenharmony_ci     * \c __DRI_BUFFER_FRONT_LEFT.
992bf215546Sopenharmony_ci     *
993bf215546Sopenharmony_ci     * \param driDrawable    Drawable whose front-buffer is to be flushed
994bf215546Sopenharmony_ci     * \param loaderPrivate  Loader's private data that was previously passed
995bf215546Sopenharmony_ci     *                       into __DRIdri2ExtensionRec::createNewDrawable
996bf215546Sopenharmony_ci     *
997bf215546Sopenharmony_ci     * \since 2
998bf215546Sopenharmony_ci     */
999bf215546Sopenharmony_ci    void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
1000bf215546Sopenharmony_ci
1001bf215546Sopenharmony_ci
1002bf215546Sopenharmony_ci    /**
1003bf215546Sopenharmony_ci     * Get list of buffers from the server
1004bf215546Sopenharmony_ci     *
1005bf215546Sopenharmony_ci     * Gets a list of buffer for the specified set of attachments.  Unlike
1006bf215546Sopenharmony_ci     * \c ::getBuffers, this function takes a list of attachments paired with
1007bf215546Sopenharmony_ci     * opaque \c unsigned \c int value describing the format of the buffer.
1008bf215546Sopenharmony_ci     * It is the responsibility of the caller to know what the service that
1009bf215546Sopenharmony_ci     * allocates the buffers will expect to receive for the format.
1010bf215546Sopenharmony_ci     *
1011bf215546Sopenharmony_ci     * \param driDrawable    Drawable whose buffers are being queried.
1012bf215546Sopenharmony_ci     * \param width          Output where the width of the buffers is stored.
1013bf215546Sopenharmony_ci     * \param height         Output where the height of the buffers is stored.
1014bf215546Sopenharmony_ci     * \param attachments    List of pairs of attachment ID and opaque format
1015bf215546Sopenharmony_ci     *                       requested for the drawable.
1016bf215546Sopenharmony_ci     * \param count          Number of attachment / format pairs stored in
1017bf215546Sopenharmony_ci     *                       \c attachments.
1018bf215546Sopenharmony_ci     * \param loaderPrivate  Loader's private data that was previously passed
1019bf215546Sopenharmony_ci     *                       into __DRIdri2ExtensionRec::createNewDrawable.
1020bf215546Sopenharmony_ci     *
1021bf215546Sopenharmony_ci     * \since 3
1022bf215546Sopenharmony_ci     */
1023bf215546Sopenharmony_ci    __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
1024bf215546Sopenharmony_ci					 int *width, int *height,
1025bf215546Sopenharmony_ci					 unsigned int *attachments, int count,
1026bf215546Sopenharmony_ci					 int *out_count, void *loaderPrivate);
1027bf215546Sopenharmony_ci
1028bf215546Sopenharmony_ci    /**
1029bf215546Sopenharmony_ci     * Return a loader capability value. If the loader doesn't know the enum,
1030bf215546Sopenharmony_ci     * it will return 0.
1031bf215546Sopenharmony_ci     *
1032bf215546Sopenharmony_ci     * \param loaderPrivate The last parameter of createNewScreen or
1033bf215546Sopenharmony_ci     *                      createNewScreen2.
1034bf215546Sopenharmony_ci     * \param cap           See the enum.
1035bf215546Sopenharmony_ci     *
1036bf215546Sopenharmony_ci     * \since 4
1037bf215546Sopenharmony_ci     */
1038bf215546Sopenharmony_ci    unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
1039bf215546Sopenharmony_ci
1040bf215546Sopenharmony_ci    /**
1041bf215546Sopenharmony_ci     * Clean up any loader state associated with an image.
1042bf215546Sopenharmony_ci     *
1043bf215546Sopenharmony_ci     * \param loaderPrivate  Loader's private data that was previously passed
1044bf215546Sopenharmony_ci     *                       into a __DRIimageExtensionRec::createImage function
1045bf215546Sopenharmony_ci     * \since 5
1046bf215546Sopenharmony_ci     */
1047bf215546Sopenharmony_ci    void (*destroyLoaderImageState)(void *loaderPrivate);
1048bf215546Sopenharmony_ci};
1049bf215546Sopenharmony_ci
1050bf215546Sopenharmony_ci/**
1051bf215546Sopenharmony_ci * This extension provides alternative screen, drawable and context
1052bf215546Sopenharmony_ci * constructors for DRI2.
1053bf215546Sopenharmony_ci */
1054bf215546Sopenharmony_ci#define __DRI_DRI2 "DRI_DRI2"
1055bf215546Sopenharmony_ci#define __DRI_DRI2_VERSION 4
1056bf215546Sopenharmony_ci
1057bf215546Sopenharmony_ci#define __DRI_API_OPENGL	0	/**< OpenGL compatibility profile */
1058bf215546Sopenharmony_ci#define __DRI_API_GLES		1	/**< OpenGL ES 1.x */
1059bf215546Sopenharmony_ci#define __DRI_API_GLES2		2	/**< OpenGL ES 2.x */
1060bf215546Sopenharmony_ci#define __DRI_API_OPENGL_CORE	3	/**< OpenGL 3.2+ core profile */
1061bf215546Sopenharmony_ci#define __DRI_API_GLES3		4	/**< OpenGL ES 3.x */
1062bf215546Sopenharmony_ci
1063bf215546Sopenharmony_ci#define __DRI_CTX_ATTRIB_MAJOR_VERSION		0
1064bf215546Sopenharmony_ci#define __DRI_CTX_ATTRIB_MINOR_VERSION		1
1065bf215546Sopenharmony_ci
1066bf215546Sopenharmony_ci/* These must alias the GLX/EGL values. */
1067bf215546Sopenharmony_ci#define __DRI_CTX_ATTRIB_FLAGS			2
1068bf215546Sopenharmony_ci#define __DRI_CTX_FLAG_DEBUG			0x00000001
1069bf215546Sopenharmony_ci#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE	0x00000002
1070bf215546Sopenharmony_ci#define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS	0x00000004
1071bf215546Sopenharmony_ci#define __DRI_CTX_FLAG_NO_ERROR			0x00000008 /* Deprecated, do not use */
1072bf215546Sopenharmony_ci/* Not yet implemented but placed here to reserve the alias with GLX */
1073bf215546Sopenharmony_ci#define __DRI_CTX_FLAG_RESET_ISOLATION          0x00000008
1074bf215546Sopenharmony_ci
1075bf215546Sopenharmony_ci#define __DRI_CTX_ATTRIB_RESET_STRATEGY		3
1076bf215546Sopenharmony_ci#define __DRI_CTX_RESET_NO_NOTIFICATION		0
1077bf215546Sopenharmony_ci#define __DRI_CTX_RESET_LOSE_CONTEXT		1
1078bf215546Sopenharmony_ci
1079bf215546Sopenharmony_ci/**
1080bf215546Sopenharmony_ci * \name Context priority levels.
1081bf215546Sopenharmony_ci */
1082bf215546Sopenharmony_ci#define __DRI_CTX_ATTRIB_PRIORITY		4
1083bf215546Sopenharmony_ci#define __DRI_CTX_PRIORITY_LOW			0
1084bf215546Sopenharmony_ci#define __DRI_CTX_PRIORITY_MEDIUM		1
1085bf215546Sopenharmony_ci#define __DRI_CTX_PRIORITY_HIGH			2
1086bf215546Sopenharmony_ci
1087bf215546Sopenharmony_ci#define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR	5
1088bf215546Sopenharmony_ci#define __DRI_CTX_RELEASE_BEHAVIOR_NONE         0
1089bf215546Sopenharmony_ci#define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH        1
1090bf215546Sopenharmony_ci
1091bf215546Sopenharmony_ci#define __DRI_CTX_ATTRIB_NO_ERROR               6
1092bf215546Sopenharmony_ci
1093bf215546Sopenharmony_ci#define __DRI_CTX_NUM_ATTRIBS                   7
1094bf215546Sopenharmony_ci
1095bf215546Sopenharmony_ci/**
1096bf215546Sopenharmony_ci * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
1097bf215546Sopenharmony_ci */
1098bf215546Sopenharmony_ci/*@{*/
1099bf215546Sopenharmony_ci/** Success! */
1100bf215546Sopenharmony_ci#define __DRI_CTX_ERROR_SUCCESS			0
1101bf215546Sopenharmony_ci
1102bf215546Sopenharmony_ci/** Memory allocation failure */
1103bf215546Sopenharmony_ci#define __DRI_CTX_ERROR_NO_MEMORY		1
1104bf215546Sopenharmony_ci
1105bf215546Sopenharmony_ci/** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
1106bf215546Sopenharmony_ci#define __DRI_CTX_ERROR_BAD_API			2
1107bf215546Sopenharmony_ci
1108bf215546Sopenharmony_ci/** Client requested an API version that the driver can't do. */
1109bf215546Sopenharmony_ci#define __DRI_CTX_ERROR_BAD_VERSION		3
1110bf215546Sopenharmony_ci
1111bf215546Sopenharmony_ci/** Client requested a flag or combination of flags the driver can't do. */
1112bf215546Sopenharmony_ci#define __DRI_CTX_ERROR_BAD_FLAG		4
1113bf215546Sopenharmony_ci
1114bf215546Sopenharmony_ci/** Client requested an attribute the driver doesn't understand. */
1115bf215546Sopenharmony_ci#define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE	5
1116bf215546Sopenharmony_ci
1117bf215546Sopenharmony_ci/** Client requested a flag the driver doesn't understand. */
1118bf215546Sopenharmony_ci#define __DRI_CTX_ERROR_UNKNOWN_FLAG		6
1119bf215546Sopenharmony_ci/*@}*/
1120bf215546Sopenharmony_ci
1121bf215546Sopenharmony_cistruct __DRIdri2ExtensionRec {
1122bf215546Sopenharmony_ci    __DRIextension base;
1123bf215546Sopenharmony_ci
1124bf215546Sopenharmony_ci    __DRIscreen *(*createNewScreen)(int screen, int fd,
1125bf215546Sopenharmony_ci				    const __DRIextension **extensions,
1126bf215546Sopenharmony_ci				    const __DRIconfig ***driver_configs,
1127bf215546Sopenharmony_ci				    void *loaderPrivate);
1128bf215546Sopenharmony_ci
1129bf215546Sopenharmony_ci   __DRIcreateNewDrawableFunc   createNewDrawable;
1130bf215546Sopenharmony_ci   __DRIcontext *(*createNewContext)(__DRIscreen *screen,
1131bf215546Sopenharmony_ci                                     const __DRIconfig *config,
1132bf215546Sopenharmony_ci                                     __DRIcontext *shared,
1133bf215546Sopenharmony_ci                                     void *loaderPrivate);
1134bf215546Sopenharmony_ci
1135bf215546Sopenharmony_ci   /* Since version 2 */
1136bf215546Sopenharmony_ci   __DRIgetAPIMaskFunc          getAPIMask;
1137bf215546Sopenharmony_ci
1138bf215546Sopenharmony_ci   __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
1139bf215546Sopenharmony_ci					   int api,
1140bf215546Sopenharmony_ci					   const __DRIconfig *config,
1141bf215546Sopenharmony_ci					   __DRIcontext *shared,
1142bf215546Sopenharmony_ci					   void *data);
1143bf215546Sopenharmony_ci
1144bf215546Sopenharmony_ci   __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
1145bf215546Sopenharmony_ci				  unsigned int attachment,
1146bf215546Sopenharmony_ci				  unsigned int format,
1147bf215546Sopenharmony_ci				  int width,
1148bf215546Sopenharmony_ci				  int height);
1149bf215546Sopenharmony_ci   void (*releaseBuffer)(__DRIscreen *screen,
1150bf215546Sopenharmony_ci			 __DRIbuffer *buffer);
1151bf215546Sopenharmony_ci
1152bf215546Sopenharmony_ci   /**
1153bf215546Sopenharmony_ci    * Create a context for a particular API with a set of attributes
1154bf215546Sopenharmony_ci    *
1155bf215546Sopenharmony_ci    * \since version 3
1156bf215546Sopenharmony_ci    *
1157bf215546Sopenharmony_ci    * \sa __DRIswrastExtensionRec::createContextAttribs
1158bf215546Sopenharmony_ci    */
1159bf215546Sopenharmony_ci   __DRIcreateContextAttribsFunc        createContextAttribs;
1160bf215546Sopenharmony_ci
1161bf215546Sopenharmony_ci   /**
1162bf215546Sopenharmony_ci    * createNewScreen with the driver's extension list passed in.
1163bf215546Sopenharmony_ci    *
1164bf215546Sopenharmony_ci    * \since version 4
1165bf215546Sopenharmony_ci    */
1166bf215546Sopenharmony_ci   __DRIcreateNewScreen2Func            createNewScreen2;
1167bf215546Sopenharmony_ci};
1168bf215546Sopenharmony_ci
1169bf215546Sopenharmony_ci
1170bf215546Sopenharmony_ci/**
1171bf215546Sopenharmony_ci * This extension provides functionality to enable various EGLImage
1172bf215546Sopenharmony_ci * extensions.
1173bf215546Sopenharmony_ci */
1174bf215546Sopenharmony_ci#define __DRI_IMAGE "DRI_IMAGE"
1175bf215546Sopenharmony_ci#define __DRI_IMAGE_VERSION 20
1176bf215546Sopenharmony_ci
1177bf215546Sopenharmony_ci/**
1178bf215546Sopenharmony_ci * These formats correspond to the similarly named MESA_FORMAT_*
1179bf215546Sopenharmony_ci * tokens, except in the native endian of the CPU.  For example, on
1180bf215546Sopenharmony_ci * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
1181bf215546Sopenharmony_ci * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
1182bf215546Sopenharmony_ci *
1183bf215546Sopenharmony_ci * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
1184bf215546Sopenharmony_ci * by the driver (YUV planar formats) but serve as a base image for
1185bf215546Sopenharmony_ci * creating sub-images for the different planes within the image.
1186bf215546Sopenharmony_ci *
1187bf215546Sopenharmony_ci * R8, GR88 and NONE should not be used with createImageFromName or
1188bf215546Sopenharmony_ci * createImage, and are returned by query from sub images created with
1189bf215546Sopenharmony_ci * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
1190bf215546Sopenharmony_ci */
1191bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_RGB565       0x1001
1192bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_XRGB8888     0x1002
1193bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_ARGB8888     0x1003
1194bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_ABGR8888     0x1004
1195bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_XBGR8888     0x1005
1196bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_R8           0x1006 /* Since version 5 */
1197bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_GR88         0x1007
1198bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_NONE         0x1008
1199bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_XRGB2101010  0x1009
1200bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_ARGB2101010  0x100a
1201bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_SARGB8       0x100b
1202bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_ARGB1555     0x100c
1203bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_R16          0x100d
1204bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_GR1616       0x100e
1205bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_YUYV         0x100f
1206bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_XBGR2101010  0x1010
1207bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_ABGR2101010  0x1011
1208bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_SABGR8       0x1012
1209bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_UYVY         0x1013
1210bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_XBGR16161616F 0x1014
1211bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_ABGR16161616F 0x1015
1212bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_SXRGB8       0x1016
1213bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_ABGR16161616 0x1017
1214bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_XBGR16161616 0x1018
1215bf215546Sopenharmony_ci
1216bf215546Sopenharmony_ci#define __DRI_IMAGE_USE_SHARE		0x0001
1217bf215546Sopenharmony_ci#define __DRI_IMAGE_USE_SCANOUT		0x0002
1218bf215546Sopenharmony_ci#define __DRI_IMAGE_USE_CURSOR		0x0004 /* Deprecated */
1219bf215546Sopenharmony_ci#define __DRI_IMAGE_USE_LINEAR		0x0008
1220bf215546Sopenharmony_ci/* The buffer will only be read by an external process after SwapBuffers,
1221bf215546Sopenharmony_ci * in contrary to gbm buffers, front buffers and fake front buffers, which
1222bf215546Sopenharmony_ci * could be read after a flush."
1223bf215546Sopenharmony_ci */
1224bf215546Sopenharmony_ci#define __DRI_IMAGE_USE_BACKBUFFER      0x0010
1225bf215546Sopenharmony_ci#define __DRI_IMAGE_USE_PROTECTED       0x0020
1226bf215546Sopenharmony_ci#define __DRI_IMAGE_USE_PRIME_BUFFER    0x0040
1227bf215546Sopenharmony_ci
1228bf215546Sopenharmony_ci
1229bf215546Sopenharmony_ci#define __DRI_IMAGE_TRANSFER_READ            0x1
1230bf215546Sopenharmony_ci#define __DRI_IMAGE_TRANSFER_WRITE           0x2
1231bf215546Sopenharmony_ci#define __DRI_IMAGE_TRANSFER_READ_WRITE      \
1232bf215546Sopenharmony_ci        (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)
1233bf215546Sopenharmony_ci
1234bf215546Sopenharmony_ci/**
1235bf215546Sopenharmony_ci * Extra fourcc formats used internally to Mesa with createImageFromNames.
1236bf215546Sopenharmony_ci * The externally-available fourccs are defined by drm_fourcc.h (DRM_FORMAT_*)
1237bf215546Sopenharmony_ci * and WL_DRM_FORMAT_* from wayland_drm.h.
1238bf215546Sopenharmony_ci *
1239bf215546Sopenharmony_ci * \since 5
1240bf215546Sopenharmony_ci */
1241bf215546Sopenharmony_ci
1242bf215546Sopenharmony_ci#define __DRI_IMAGE_FOURCC_SARGB8888	0x83324258
1243bf215546Sopenharmony_ci#define __DRI_IMAGE_FOURCC_SABGR8888	0x84324258
1244bf215546Sopenharmony_ci#define __DRI_IMAGE_FOURCC_SXRGB8888	0x85324258
1245bf215546Sopenharmony_ci
1246bf215546Sopenharmony_ci/**
1247bf215546Sopenharmony_ci * Queryable on images created by createImageFromNames.
1248bf215546Sopenharmony_ci *
1249bf215546Sopenharmony_ci * RGB and RGBA might be usable directly as images, but it's still
1250bf215546Sopenharmony_ci * recommended to call fromPlanar with plane == 0.
1251bf215546Sopenharmony_ci *
1252bf215546Sopenharmony_ci * Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create
1253bf215546Sopenharmony_ci * usable sub-images, sampling from images return raw YUV data and
1254bf215546Sopenharmony_ci * color conversion needs to be done in the shader.
1255bf215546Sopenharmony_ci *
1256bf215546Sopenharmony_ci * \since 5
1257bf215546Sopenharmony_ci */
1258bf215546Sopenharmony_ci
1259bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_RGB	0x3001
1260bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_RGBA	0x3002
1261bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_Y_U_V	0x3003
1262bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_Y_UV	0x3004
1263bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_Y_XUXV	0x3005
1264bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_Y_UXVX	0x3008
1265bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_AYUV	0x3009
1266bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_XYUV	0x300A
1267bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_R	0x3006
1268bf215546Sopenharmony_ci#define __DRI_IMAGE_COMPONENTS_RG	0x3007
1269bf215546Sopenharmony_ci
1270bf215546Sopenharmony_ci
1271bf215546Sopenharmony_ci/**
1272bf215546Sopenharmony_ci * queryImage attributes
1273bf215546Sopenharmony_ci */
1274bf215546Sopenharmony_ci
1275bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_STRIDE	0x2000
1276bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_HANDLE	0x2001
1277bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_NAME		0x2002
1278bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_FORMAT	0x2003 /* available in versions 3+ */
1279bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_WIDTH	0x2004 /* available in versions 4+ */
1280bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_HEIGHT	0x2005
1281bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_COMPONENTS	0x2006 /* available in versions 5+ */
1282bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_FD           0x2007 /* available in versions
1283bf215546Sopenharmony_ci                                                * 7+. Each query will return a
1284bf215546Sopenharmony_ci                                                * new fd. */
1285bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_FOURCC       0x2008 /* available in versions 11 */
1286bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_NUM_PLANES   0x2009 /* available in versions 11 */
1287bf215546Sopenharmony_ci
1288bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
1289bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */
1290bf215546Sopenharmony_ci#define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */
1291bf215546Sopenharmony_ci
1292bf215546Sopenharmony_cienum __DRIYUVColorSpace {
1293bf215546Sopenharmony_ci   __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
1294bf215546Sopenharmony_ci   __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
1295bf215546Sopenharmony_ci   __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
1296bf215546Sopenharmony_ci   __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
1297bf215546Sopenharmony_ci};
1298bf215546Sopenharmony_ci
1299bf215546Sopenharmony_cienum __DRISampleRange {
1300bf215546Sopenharmony_ci   __DRI_YUV_RANGE_UNDEFINED = 0,
1301bf215546Sopenharmony_ci   __DRI_YUV_FULL_RANGE = 0x3282,
1302bf215546Sopenharmony_ci   __DRI_YUV_NARROW_RANGE = 0x3283
1303bf215546Sopenharmony_ci};
1304bf215546Sopenharmony_ci
1305bf215546Sopenharmony_cienum __DRIChromaSiting {
1306bf215546Sopenharmony_ci   __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
1307bf215546Sopenharmony_ci   __DRI_YUV_CHROMA_SITING_0 = 0x3284,
1308bf215546Sopenharmony_ci   __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
1309bf215546Sopenharmony_ci};
1310bf215546Sopenharmony_ci
1311bf215546Sopenharmony_ci/**
1312bf215546Sopenharmony_ci * \name Reasons that __DRIimageExtensionRec::createImageFromTexture or
1313bf215546Sopenharmony_ci * __DRIimageExtensionRec::createImageFromDmaBufs might fail
1314bf215546Sopenharmony_ci */
1315bf215546Sopenharmony_ci/*@{*/
1316bf215546Sopenharmony_ci/** Success! */
1317bf215546Sopenharmony_ci#define __DRI_IMAGE_ERROR_SUCCESS       0
1318bf215546Sopenharmony_ci
1319bf215546Sopenharmony_ci/** Memory allocation failure */
1320bf215546Sopenharmony_ci#define __DRI_IMAGE_ERROR_BAD_ALLOC     1
1321bf215546Sopenharmony_ci
1322bf215546Sopenharmony_ci/** Client requested an invalid attribute */
1323bf215546Sopenharmony_ci#define __DRI_IMAGE_ERROR_BAD_MATCH     2
1324bf215546Sopenharmony_ci
1325bf215546Sopenharmony_ci/** Client requested an invalid texture object */
1326bf215546Sopenharmony_ci#define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
1327bf215546Sopenharmony_ci
1328bf215546Sopenharmony_ci/** Client requested an invalid pitch and/or offset */
1329bf215546Sopenharmony_ci#define __DRI_IMAGE_ERROR_BAD_ACCESS    4
1330bf215546Sopenharmony_ci/*@}*/
1331bf215546Sopenharmony_ci
1332bf215546Sopenharmony_ci/**
1333bf215546Sopenharmony_ci * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
1334bf215546Sopenharmony_ci */
1335bf215546Sopenharmony_ci/*@{*/
1336bf215546Sopenharmony_ci#define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
1337bf215546Sopenharmony_ci/*@}*/
1338bf215546Sopenharmony_ci
1339bf215546Sopenharmony_ci/**
1340bf215546Sopenharmony_ci * blitImage flags
1341bf215546Sopenharmony_ci */
1342bf215546Sopenharmony_ci
1343bf215546Sopenharmony_ci#define __BLIT_FLAG_FLUSH		0x0001
1344bf215546Sopenharmony_ci#define __BLIT_FLAG_FINISH		0x0002
1345bf215546Sopenharmony_ci
1346bf215546Sopenharmony_ci/**
1347bf215546Sopenharmony_ci * Flags for createImageFromDmaBufs3 and createImageFromFds2
1348bf215546Sopenharmony_ci */
1349bf215546Sopenharmony_ci#define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001
1350bf215546Sopenharmony_ci#define __DRI_IMAGE_PRIME_LINEAR_BUFFER    0x00000002
1351bf215546Sopenharmony_ci
1352bf215546Sopenharmony_ci/**
1353bf215546Sopenharmony_ci * queryDmaBufFormatModifierAttribs attributes
1354bf215546Sopenharmony_ci */
1355bf215546Sopenharmony_ci
1356bf215546Sopenharmony_ci/* Available in version 16 */
1357bf215546Sopenharmony_ci#define __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT   0x0001
1358bf215546Sopenharmony_ci
1359bf215546Sopenharmony_citypedef struct __DRIimageRec          __DRIimage;
1360bf215546Sopenharmony_citypedef struct __DRIimageExtensionRec __DRIimageExtension;
1361bf215546Sopenharmony_cistruct __DRIimageExtensionRec {
1362bf215546Sopenharmony_ci    __DRIextension base;
1363bf215546Sopenharmony_ci
1364bf215546Sopenharmony_ci    __DRIimage *(*createImageFromName)(__DRIscreen *screen,
1365bf215546Sopenharmony_ci				       int width, int height, int format,
1366bf215546Sopenharmony_ci				       int name, int pitch,
1367bf215546Sopenharmony_ci				       void *loaderPrivate);
1368bf215546Sopenharmony_ci
1369bf215546Sopenharmony_ci    /* Deprecated since version 17; see createImageFromRenderbuffer2 */
1370bf215546Sopenharmony_ci    __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
1371bf215546Sopenharmony_ci					       int renderbuffer,
1372bf215546Sopenharmony_ci					       void *loaderPrivate);
1373bf215546Sopenharmony_ci
1374bf215546Sopenharmony_ci    void (*destroyImage)(__DRIimage *image);
1375bf215546Sopenharmony_ci
1376bf215546Sopenharmony_ci    __DRIimage *(*createImage)(__DRIscreen *screen,
1377bf215546Sopenharmony_ci			       int width, int height, int format,
1378bf215546Sopenharmony_ci			       unsigned int use,
1379bf215546Sopenharmony_ci			       void *loaderPrivate);
1380bf215546Sopenharmony_ci
1381bf215546Sopenharmony_ci   unsigned char (*queryImage)(__DRIimage *image, int attrib, int *value);
1382bf215546Sopenharmony_ci
1383bf215546Sopenharmony_ci   /**
1384bf215546Sopenharmony_ci    * The new __DRIimage will share the content with the old one, see dup(2).
1385bf215546Sopenharmony_ci    */
1386bf215546Sopenharmony_ci   __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
1387bf215546Sopenharmony_ci
1388bf215546Sopenharmony_ci   /**
1389bf215546Sopenharmony_ci    * Validate that a __DRIimage can be used a certain way.
1390bf215546Sopenharmony_ci    *
1391bf215546Sopenharmony_ci    * \since 2
1392bf215546Sopenharmony_ci    */
1393bf215546Sopenharmony_ci   unsigned char (*validateUsage)(__DRIimage *image, unsigned int use);
1394bf215546Sopenharmony_ci
1395bf215546Sopenharmony_ci   /**
1396bf215546Sopenharmony_ci    * Unlike createImageFromName __DRI_IMAGE_FORMAT is not used but instead
1397bf215546Sopenharmony_ci    * DRM_FORMAT_*, and strides are in bytes not pixels. Stride is
1398bf215546Sopenharmony_ci    * also per block and not per pixel (for non-RGB, see gallium blocks).
1399bf215546Sopenharmony_ci    *
1400bf215546Sopenharmony_ci    * \since 5
1401bf215546Sopenharmony_ci    */
1402bf215546Sopenharmony_ci   __DRIimage *(*createImageFromNames)(__DRIscreen *screen,
1403bf215546Sopenharmony_ci                                       int width, int height, int fourcc,
1404bf215546Sopenharmony_ci                                       int *names, int num_names,
1405bf215546Sopenharmony_ci                                       int *strides, int *offsets,
1406bf215546Sopenharmony_ci                                       void *loaderPrivate);
1407bf215546Sopenharmony_ci
1408bf215546Sopenharmony_ci   /**
1409bf215546Sopenharmony_ci    * Create an image out of a sub-region of a parent image.  This
1410bf215546Sopenharmony_ci    * entry point lets us create individual __DRIimages for different
1411bf215546Sopenharmony_ci    * planes in a planar buffer (typically yuv), for example.  While a
1412bf215546Sopenharmony_ci    * sub-image shares the underlying buffer object with the parent
1413bf215546Sopenharmony_ci    * image and other sibling sub-images, the life times of parent and
1414bf215546Sopenharmony_ci    * sub-images are not dependent.  Destroying the parent or a
1415bf215546Sopenharmony_ci    * sub-image doesn't affect other images.  The underlying buffer
1416bf215546Sopenharmony_ci    * object is free when no __DRIimage remains that references it.
1417bf215546Sopenharmony_ci    *
1418bf215546Sopenharmony_ci    * Sub-images may overlap, but rendering to overlapping sub-images
1419bf215546Sopenharmony_ci    * is undefined.
1420bf215546Sopenharmony_ci    *
1421bf215546Sopenharmony_ci    * \since 5
1422bf215546Sopenharmony_ci    */
1423bf215546Sopenharmony_ci    __DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
1424bf215546Sopenharmony_ci                              void *loaderPrivate);
1425bf215546Sopenharmony_ci
1426bf215546Sopenharmony_ci    /**
1427bf215546Sopenharmony_ci     * Create image from texture.
1428bf215546Sopenharmony_ci     *
1429bf215546Sopenharmony_ci     * \since 6
1430bf215546Sopenharmony_ci     */
1431bf215546Sopenharmony_ci   __DRIimage *(*createImageFromTexture)(__DRIcontext *context,
1432bf215546Sopenharmony_ci                                         int target,
1433bf215546Sopenharmony_ci                                         unsigned texture,
1434bf215546Sopenharmony_ci                                         int depth,
1435bf215546Sopenharmony_ci                                         int level,
1436bf215546Sopenharmony_ci                                         unsigned *error,
1437bf215546Sopenharmony_ci                                         void *loaderPrivate);
1438bf215546Sopenharmony_ci   /**
1439bf215546Sopenharmony_ci    * Like createImageFromNames, but takes a prime fd instead.
1440bf215546Sopenharmony_ci    *
1441bf215546Sopenharmony_ci    * \since 7
1442bf215546Sopenharmony_ci    */
1443bf215546Sopenharmony_ci   __DRIimage *(*createImageFromFds)(__DRIscreen *screen,
1444bf215546Sopenharmony_ci                                     int width, int height, int fourcc,
1445bf215546Sopenharmony_ci                                     int *fds, int num_fds,
1446bf215546Sopenharmony_ci                                     int *strides, int *offsets,
1447bf215546Sopenharmony_ci                                     void *loaderPrivate);
1448bf215546Sopenharmony_ci
1449bf215546Sopenharmony_ci   /**
1450bf215546Sopenharmony_ci    * Like createImageFromFds, but takes additional attributes.
1451bf215546Sopenharmony_ci    *
1452bf215546Sopenharmony_ci    * For EGL_EXT_image_dma_buf_import.
1453bf215546Sopenharmony_ci    *
1454bf215546Sopenharmony_ci    * \since 8
1455bf215546Sopenharmony_ci    */
1456bf215546Sopenharmony_ci   __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
1457bf215546Sopenharmony_ci                                         int width, int height, int fourcc,
1458bf215546Sopenharmony_ci                                         int *fds, int num_fds,
1459bf215546Sopenharmony_ci                                         int *strides, int *offsets,
1460bf215546Sopenharmony_ci                                         enum __DRIYUVColorSpace color_space,
1461bf215546Sopenharmony_ci                                         enum __DRISampleRange sample_range,
1462bf215546Sopenharmony_ci                                         enum __DRIChromaSiting horiz_siting,
1463bf215546Sopenharmony_ci                                         enum __DRIChromaSiting vert_siting,
1464bf215546Sopenharmony_ci                                         unsigned *error,
1465bf215546Sopenharmony_ci                                         void *loaderPrivate);
1466bf215546Sopenharmony_ci
1467bf215546Sopenharmony_ci   /**
1468bf215546Sopenharmony_ci    * Blit a part of a __DRIimage to another and flushes
1469bf215546Sopenharmony_ci    *
1470bf215546Sopenharmony_ci    * flush_flag:
1471bf215546Sopenharmony_ci    *    0:                  no flush
1472bf215546Sopenharmony_ci    *    __BLIT_FLAG_FLUSH:  flush after the blit operation
1473bf215546Sopenharmony_ci    *    __BLIT_FLAG_FINISH: flush and wait the blit finished
1474bf215546Sopenharmony_ci    *
1475bf215546Sopenharmony_ci    * \since 9
1476bf215546Sopenharmony_ci    */
1477bf215546Sopenharmony_ci   void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
1478bf215546Sopenharmony_ci                     int dstx0, int dsty0, int dstwidth, int dstheight,
1479bf215546Sopenharmony_ci                     int srcx0, int srcy0, int srcwidth, int srcheight,
1480bf215546Sopenharmony_ci                     int flush_flag);
1481bf215546Sopenharmony_ci
1482bf215546Sopenharmony_ci   /**
1483bf215546Sopenharmony_ci    * Query for general capabilities of the driver that concern
1484bf215546Sopenharmony_ci    * buffer sharing and image importing.
1485bf215546Sopenharmony_ci    *
1486bf215546Sopenharmony_ci    * \since 10
1487bf215546Sopenharmony_ci    */
1488bf215546Sopenharmony_ci   int (*getCapabilities)(__DRIscreen *screen);
1489bf215546Sopenharmony_ci
1490bf215546Sopenharmony_ci   /**
1491bf215546Sopenharmony_ci    * Returns a map of the specified region of a __DRIimage for the specified usage.
1492bf215546Sopenharmony_ci    *
1493bf215546Sopenharmony_ci    * flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the
1494bf215546Sopenharmony_ci    * mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ
1495bf215546Sopenharmony_ci    * is not included in the flags, the buffer content at map time is
1496bf215546Sopenharmony_ci    * undefined. Users wanting to modify the mapping must include
1497bf215546Sopenharmony_ci    * __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not
1498bf215546Sopenharmony_ci    * included, behaviour when writing the mapping is undefined.
1499bf215546Sopenharmony_ci    *
1500bf215546Sopenharmony_ci    * Returns the byte stride in *stride, and an opaque pointer to data
1501bf215546Sopenharmony_ci    * tracking the mapping in **data, which must be passed to unmapImage().
1502bf215546Sopenharmony_ci    *
1503bf215546Sopenharmony_ci    * \since 12
1504bf215546Sopenharmony_ci    */
1505bf215546Sopenharmony_ci   void *(*mapImage)(__DRIcontext *context, __DRIimage *image,
1506bf215546Sopenharmony_ci                     int x0, int y0, int width, int height,
1507bf215546Sopenharmony_ci                     unsigned int flags, int *stride, void **data);
1508bf215546Sopenharmony_ci
1509bf215546Sopenharmony_ci   /**
1510bf215546Sopenharmony_ci    * Unmap a previously mapped __DRIimage
1511bf215546Sopenharmony_ci    *
1512bf215546Sopenharmony_ci    * \since 12
1513bf215546Sopenharmony_ci    */
1514bf215546Sopenharmony_ci   void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);
1515bf215546Sopenharmony_ci
1516bf215546Sopenharmony_ci
1517bf215546Sopenharmony_ci   /**
1518bf215546Sopenharmony_ci    * Creates an image with implementation's favorite modifiers.
1519bf215546Sopenharmony_ci    *
1520bf215546Sopenharmony_ci    * This acts like createImage except there is a list of modifiers passed in
1521bf215546Sopenharmony_ci    * which the implementation may selectively use to create the DRIimage. The
1522bf215546Sopenharmony_ci    * result should be the implementation selects one modifier (perhaps it would
1523bf215546Sopenharmony_ci    * hold on to a few and later pick).
1524bf215546Sopenharmony_ci    *
1525bf215546Sopenharmony_ci    * The created image should be destroyed with destroyImage().
1526bf215546Sopenharmony_ci    *
1527bf215546Sopenharmony_ci    * Returns the new DRIimage. The chosen modifier can be obtained later on
1528bf215546Sopenharmony_ci    * and passed back to things like the kernel's AddFB2 interface.
1529bf215546Sopenharmony_ci    *
1530bf215546Sopenharmony_ci    * \sa __DRIimageRec::createImage
1531bf215546Sopenharmony_ci    *
1532bf215546Sopenharmony_ci    * \since 14
1533bf215546Sopenharmony_ci    */
1534bf215546Sopenharmony_ci   __DRIimage *(*createImageWithModifiers)(__DRIscreen *screen,
1535bf215546Sopenharmony_ci                                           int width, int height, int format,
1536bf215546Sopenharmony_ci                                           const uint64_t *modifiers,
1537bf215546Sopenharmony_ci                                           const unsigned int modifier_count,
1538bf215546Sopenharmony_ci                                           void *loaderPrivate);
1539bf215546Sopenharmony_ci
1540bf215546Sopenharmony_ci   /*
1541bf215546Sopenharmony_ci    * Like createImageFromDmaBufs, but takes also format modifiers.
1542bf215546Sopenharmony_ci    *
1543bf215546Sopenharmony_ci    * For EGL_EXT_image_dma_buf_import_modifiers.
1544bf215546Sopenharmony_ci    *
1545bf215546Sopenharmony_ci    * \since 15
1546bf215546Sopenharmony_ci    */
1547bf215546Sopenharmony_ci   __DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen,
1548bf215546Sopenharmony_ci                                          int width, int height, int fourcc,
1549bf215546Sopenharmony_ci                                          uint64_t modifier,
1550bf215546Sopenharmony_ci                                          int *fds, int num_fds,
1551bf215546Sopenharmony_ci                                          int *strides, int *offsets,
1552bf215546Sopenharmony_ci                                          enum __DRIYUVColorSpace color_space,
1553bf215546Sopenharmony_ci                                          enum __DRISampleRange sample_range,
1554bf215546Sopenharmony_ci                                          enum __DRIChromaSiting horiz_siting,
1555bf215546Sopenharmony_ci                                          enum __DRIChromaSiting vert_siting,
1556bf215546Sopenharmony_ci                                          unsigned *error,
1557bf215546Sopenharmony_ci                                          void *loaderPrivate);
1558bf215546Sopenharmony_ci
1559bf215546Sopenharmony_ci   /*
1560bf215546Sopenharmony_ci    * dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers.
1561bf215546Sopenharmony_ci    *
1562bf215546Sopenharmony_ci    * \param max      Maximum number of formats that can be accomodated into
1563bf215546Sopenharmony_ci    *                 \param formats. If zero, no formats are returned -
1564bf215546Sopenharmony_ci    *                 instead, the driver returns the total number of
1565bf215546Sopenharmony_ci    *                 supported dmabuf formats in \param count.
1566bf215546Sopenharmony_ci    * \param formats  Buffer to fill formats into.
1567bf215546Sopenharmony_ci    * \param count    Count of formats returned, or, total number of
1568bf215546Sopenharmony_ci    *                 supported formats in case \param max is zero.
1569bf215546Sopenharmony_ci    *
1570bf215546Sopenharmony_ci    * Returns true on success.
1571bf215546Sopenharmony_ci    *
1572bf215546Sopenharmony_ci    * \since 15
1573bf215546Sopenharmony_ci    */
1574bf215546Sopenharmony_ci   unsigned char (*queryDmaBufFormats)(__DRIscreen *screen, int max,
1575bf215546Sopenharmony_ci                                       int *formats, int *count);
1576bf215546Sopenharmony_ci
1577bf215546Sopenharmony_ci   /*
1578bf215546Sopenharmony_ci    * dmabuf format modifier query for a given format to support
1579bf215546Sopenharmony_ci    * EGL_EXT_image_dma_buf_import_modifiers.
1580bf215546Sopenharmony_ci    *
1581bf215546Sopenharmony_ci    * \param fourcc    The format to query modifiers for. If this format
1582bf215546Sopenharmony_ci    *                  is not supported by the driver, return false.
1583bf215546Sopenharmony_ci    * \param max       Maximum number of modifiers that can be accomodated in
1584bf215546Sopenharmony_ci    *                  \param modifiers. If zero, no modifiers are returned -
1585bf215546Sopenharmony_ci    *                  instead, the driver returns the total number of
1586bf215546Sopenharmony_ci    *                  modifiers for \param format in \param count.
1587bf215546Sopenharmony_ci    * \param modifiers Buffer to fill modifiers into.
1588bf215546Sopenharmony_ci    * \param count     Count of the modifiers returned, or, total number of
1589bf215546Sopenharmony_ci    *                  supported modifiers for \param fourcc in case
1590bf215546Sopenharmony_ci    *                  \param max is zero.
1591bf215546Sopenharmony_ci    *
1592bf215546Sopenharmony_ci    * Returns true upon success.
1593bf215546Sopenharmony_ci    *
1594bf215546Sopenharmony_ci    * \since 15
1595bf215546Sopenharmony_ci    */
1596bf215546Sopenharmony_ci   unsigned char (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc,
1597bf215546Sopenharmony_ci                                         int max, uint64_t *modifiers,
1598bf215546Sopenharmony_ci                                         unsigned int *external_only,
1599bf215546Sopenharmony_ci                                         int *count);
1600bf215546Sopenharmony_ci
1601bf215546Sopenharmony_ci   /**
1602bf215546Sopenharmony_ci    * dmabuf format modifier attribute query for a given format and modifier.
1603bf215546Sopenharmony_ci    *
1604bf215546Sopenharmony_ci    * \param fourcc    The format to query. If this format is not supported by
1605bf215546Sopenharmony_ci    *                  the driver, return false.
1606bf215546Sopenharmony_ci    * \param modifier  The modifier to query. If this format+modifier is not
1607bf215546Sopenharmony_ci    *                  supported by the driver, return false.
1608bf215546Sopenharmony_ci    * \param attrib    The __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB to query.
1609bf215546Sopenharmony_ci    * \param value     A pointer to where to store the result of the query.
1610bf215546Sopenharmony_ci    *
1611bf215546Sopenharmony_ci    * Returns true upon success.
1612bf215546Sopenharmony_ci    *
1613bf215546Sopenharmony_ci    * \since 16
1614bf215546Sopenharmony_ci    */
1615bf215546Sopenharmony_ci   unsigned char (*queryDmaBufFormatModifierAttribs)(__DRIscreen *screen,
1616bf215546Sopenharmony_ci                                                     uint32_t fourcc,
1617bf215546Sopenharmony_ci                                                     uint64_t modifier,
1618bf215546Sopenharmony_ci                                                     int attrib,
1619bf215546Sopenharmony_ci                                                     uint64_t *value);
1620bf215546Sopenharmony_ci
1621bf215546Sopenharmony_ci   /**
1622bf215546Sopenharmony_ci    * Create a DRI image from the given renderbuffer.
1623bf215546Sopenharmony_ci    *
1624bf215546Sopenharmony_ci    * \param context       the current DRI context
1625bf215546Sopenharmony_ci    * \param renderbuffer  the GL name of the renderbuffer
1626bf215546Sopenharmony_ci    * \param loaderPrivate for callbacks into the loader related to the image
1627bf215546Sopenharmony_ci    * \param error         will be set to one of __DRI_IMAGE_ERROR_xxx
1628bf215546Sopenharmony_ci    * \return the newly created image on success, or NULL otherwise
1629bf215546Sopenharmony_ci    *
1630bf215546Sopenharmony_ci    * \since 17
1631bf215546Sopenharmony_ci    */
1632bf215546Sopenharmony_ci    __DRIimage *(*createImageFromRenderbuffer2)(__DRIcontext *context,
1633bf215546Sopenharmony_ci                                                int renderbuffer,
1634bf215546Sopenharmony_ci                                                void *loaderPrivate,
1635bf215546Sopenharmony_ci                                                unsigned *error);
1636bf215546Sopenharmony_ci
1637bf215546Sopenharmony_ci   /*
1638bf215546Sopenharmony_ci    * Like createImageFromDmaBufs2, but with an added flags parameter.
1639bf215546Sopenharmony_ci    *
1640bf215546Sopenharmony_ci    * See __DRI_IMAGE_*_FLAG for valid definitions of flags.
1641bf215546Sopenharmony_ci    *
1642bf215546Sopenharmony_ci    * \since 18
1643bf215546Sopenharmony_ci    */
1644bf215546Sopenharmony_ci   __DRIimage *(*createImageFromDmaBufs3)(__DRIscreen *screen,
1645bf215546Sopenharmony_ci                                          int width, int height, int fourcc,
1646bf215546Sopenharmony_ci                                          uint64_t modifier,
1647bf215546Sopenharmony_ci                                          int *fds, int num_fds,
1648bf215546Sopenharmony_ci                                          int *strides, int *offsets,
1649bf215546Sopenharmony_ci                                          enum __DRIYUVColorSpace color_space,
1650bf215546Sopenharmony_ci                                          enum __DRISampleRange sample_range,
1651bf215546Sopenharmony_ci                                          enum __DRIChromaSiting horiz_siting,
1652bf215546Sopenharmony_ci                                          enum __DRIChromaSiting vert_siting,
1653bf215546Sopenharmony_ci                                          uint32_t flags,
1654bf215546Sopenharmony_ci                                          unsigned *error,
1655bf215546Sopenharmony_ci                                          void *loaderPrivate);
1656bf215546Sopenharmony_ci
1657bf215546Sopenharmony_ci   /**
1658bf215546Sopenharmony_ci    * Creates an image with implementation's favorite modifiers and the
1659bf215546Sopenharmony_ci    * provided usage flags.
1660bf215546Sopenharmony_ci    *
1661bf215546Sopenharmony_ci    * This acts like createImageWithModifiers except usage is also specified.
1662bf215546Sopenharmony_ci    *
1663bf215546Sopenharmony_ci    * The created image should be destroyed with destroyImage().
1664bf215546Sopenharmony_ci    *
1665bf215546Sopenharmony_ci    * Returns the new DRIimage. The chosen modifier can be obtained later on
1666bf215546Sopenharmony_ci    * and passed back to things like the kernel's AddFB2 interface.
1667bf215546Sopenharmony_ci    *
1668bf215546Sopenharmony_ci    * \sa __DRIimageRec::createImage
1669bf215546Sopenharmony_ci    *
1670bf215546Sopenharmony_ci    * \since 19
1671bf215546Sopenharmony_ci    */
1672bf215546Sopenharmony_ci   __DRIimage *(*createImageWithModifiers2)(__DRIscreen *screen,
1673bf215546Sopenharmony_ci                                            int width, int height, int format,
1674bf215546Sopenharmony_ci                                            const uint64_t *modifiers,
1675bf215546Sopenharmony_ci                                            const unsigned int modifier_count,
1676bf215546Sopenharmony_ci                                            unsigned int use,
1677bf215546Sopenharmony_ci                                            void *loaderPrivate);
1678bf215546Sopenharmony_ci
1679bf215546Sopenharmony_ci   /**
1680bf215546Sopenharmony_ci    * Like createImageFromFds, but with an added flag parameter.
1681bf215546Sopenharmony_ci    *
1682bf215546Sopenharmony_ci    * See __DRI_IMAGE_*_FLAG for valid definitions of flags.
1683bf215546Sopenharmony_ci    *
1684bf215546Sopenharmony_ci    * \since 20
1685bf215546Sopenharmony_ci    */
1686bf215546Sopenharmony_ci   __DRIimage *(*createImageFromFds2)(__DRIscreen *screen,
1687bf215546Sopenharmony_ci                                      int width, int height, int fourcc,
1688bf215546Sopenharmony_ci                                      int *fds, int num_fds,
1689bf215546Sopenharmony_ci                                      uint32_t flags,
1690bf215546Sopenharmony_ci                                      int *strides, int *offsets,
1691bf215546Sopenharmony_ci                                      void *loaderPrivate);
1692bf215546Sopenharmony_ci
1693bf215546Sopenharmony_ci   /**
1694bf215546Sopenharmony_ci    * Set an in-fence-fd on the image.  If a fence-fd is already set
1695bf215546Sopenharmony_ci    * (but not yet consumed), the existing and new fence will be merged
1696bf215546Sopenharmony_ci    *
1697bf215546Sopenharmony_ci    * This does *not* take ownership of the fd.  The fd does not need
1698bf215546Sopenharmony_ci    * to be kept alive once the call has returned.
1699bf215546Sopenharmony_ci    *
1700bf215546Sopenharmony_ci    * \since 21
1701bf215546Sopenharmony_ci    */
1702bf215546Sopenharmony_ci   void (*setInFenceFd)(__DRIimage *image, int fd);
1703bf215546Sopenharmony_ci};
1704bf215546Sopenharmony_ci
1705bf215546Sopenharmony_ci
1706bf215546Sopenharmony_ci/**
1707bf215546Sopenharmony_ci * This extension must be implemented by the loader and passed to the
1708bf215546Sopenharmony_ci * driver at screen creation time.  The EGLImage entry points in the
1709bf215546Sopenharmony_ci * various client APIs take opaque EGLImage handles and use this
1710bf215546Sopenharmony_ci * extension to map them to a __DRIimage.  At version 1, this
1711bf215546Sopenharmony_ci * extensions allows mapping EGLImage pointers to __DRIimage pointers,
1712bf215546Sopenharmony_ci * but future versions could support other EGLImage-like, opaque types
1713bf215546Sopenharmony_ci * with new lookup functions.
1714bf215546Sopenharmony_ci */
1715bf215546Sopenharmony_ci#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
1716bf215546Sopenharmony_ci#define __DRI_IMAGE_LOOKUP_VERSION 2
1717bf215546Sopenharmony_ci
1718bf215546Sopenharmony_citypedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
1719bf215546Sopenharmony_cistruct __DRIimageLookupExtensionRec {
1720bf215546Sopenharmony_ci    __DRIextension base;
1721bf215546Sopenharmony_ci
1722bf215546Sopenharmony_ci    /**
1723bf215546Sopenharmony_ci     * Lookup EGLImage without validated. Equivalent to call
1724bf215546Sopenharmony_ci     * validateEGLImage() then lookupEGLImageValidated().
1725bf215546Sopenharmony_ci     *
1726bf215546Sopenharmony_ci     * \since 1
1727bf215546Sopenharmony_ci     */
1728bf215546Sopenharmony_ci    __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
1729bf215546Sopenharmony_ci				  void *loaderPrivate);
1730bf215546Sopenharmony_ci
1731bf215546Sopenharmony_ci    /**
1732bf215546Sopenharmony_ci     * Check if EGLImage is associated with the EGL display before lookup with
1733bf215546Sopenharmony_ci     * lookupEGLImageValidated(). It will hold EGLDisplay.Mutex, so is separated
1734bf215546Sopenharmony_ci     * out from lookupEGLImage() to avoid deadlock.
1735bf215546Sopenharmony_ci     *
1736bf215546Sopenharmony_ci     * \since 2
1737bf215546Sopenharmony_ci     */
1738bf215546Sopenharmony_ci    unsigned char (*validateEGLImage)(void *image, void *loaderPrivate);
1739bf215546Sopenharmony_ci
1740bf215546Sopenharmony_ci    /**
1741bf215546Sopenharmony_ci     * Lookup EGLImage after validateEGLImage(). No lock in this function.
1742bf215546Sopenharmony_ci     *
1743bf215546Sopenharmony_ci     * \since 2
1744bf215546Sopenharmony_ci     */
1745bf215546Sopenharmony_ci    __DRIimage *(*lookupEGLImageValidated)(void *image, void *loaderPrivate);
1746bf215546Sopenharmony_ci};
1747bf215546Sopenharmony_ci
1748bf215546Sopenharmony_ci/**
1749bf215546Sopenharmony_ci * This extension allows for common DRI2 options
1750bf215546Sopenharmony_ci */
1751bf215546Sopenharmony_ci#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
1752bf215546Sopenharmony_ci#define __DRI2_CONFIG_QUERY_VERSION 2
1753bf215546Sopenharmony_ci
1754bf215546Sopenharmony_citypedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
1755bf215546Sopenharmony_cistruct __DRI2configQueryExtensionRec {
1756bf215546Sopenharmony_ci   __DRIextension base;
1757bf215546Sopenharmony_ci
1758bf215546Sopenharmony_ci   int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);
1759bf215546Sopenharmony_ci   int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
1760bf215546Sopenharmony_ci   int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
1761bf215546Sopenharmony_ci   int (*configQuerys)(__DRIscreen *screen, const char *var, char **val);
1762bf215546Sopenharmony_ci};
1763bf215546Sopenharmony_ci
1764bf215546Sopenharmony_ci/**
1765bf215546Sopenharmony_ci * Robust context driver extension.
1766bf215546Sopenharmony_ci *
1767bf215546Sopenharmony_ci * Existence of this extension means the driver can accept the
1768bf215546Sopenharmony_ci * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
1769bf215546Sopenharmony_ci * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
1770bf215546Sopenharmony_ci * \c __DRIdri2ExtensionRec::createContextAttribs.
1771bf215546Sopenharmony_ci */
1772bf215546Sopenharmony_ci#define __DRI2_ROBUSTNESS "DRI_Robustness"
1773bf215546Sopenharmony_ci#define __DRI2_ROBUSTNESS_VERSION 1
1774bf215546Sopenharmony_ci
1775bf215546Sopenharmony_citypedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
1776bf215546Sopenharmony_cistruct __DRIrobustnessExtensionRec {
1777bf215546Sopenharmony_ci   __DRIextension base;
1778bf215546Sopenharmony_ci};
1779bf215546Sopenharmony_ci
1780bf215546Sopenharmony_ci/**
1781bf215546Sopenharmony_ci * No-error context driver extension (deprecated).
1782bf215546Sopenharmony_ci *
1783bf215546Sopenharmony_ci * Existence of this extension means the driver can accept the
1784bf215546Sopenharmony_ci * __DRI_CTX_FLAG_NO_ERROR flag.
1785bf215546Sopenharmony_ci *
1786bf215546Sopenharmony_ci * This extension is deprecated, and modern loaders will not use it. Please
1787bf215546Sopenharmony_ci * use __DRI2_RENDERER_HAS_NO_ERROR_CONTEXT instead.
1788bf215546Sopenharmony_ci */
1789bf215546Sopenharmony_ci#define __DRI2_NO_ERROR "DRI_NoError"
1790bf215546Sopenharmony_ci#define __DRI2_NO_ERROR_VERSION 1
1791bf215546Sopenharmony_ci
1792bf215546Sopenharmony_citypedef struct __DRInoErrorExtensionRec {
1793bf215546Sopenharmony_ci   __DRIextension base;
1794bf215546Sopenharmony_ci} __DRInoErrorExtension;
1795bf215546Sopenharmony_ci
1796bf215546Sopenharmony_ci/*
1797bf215546Sopenharmony_ci * Flush control driver extension.
1798bf215546Sopenharmony_ci *
1799bf215546Sopenharmony_ci * Existence of this extension means the driver can accept the
1800bf215546Sopenharmony_ci * \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in
1801bf215546Sopenharmony_ci * \c __DRIdri2ExtensionRec::createContextAttribs.
1802bf215546Sopenharmony_ci */
1803bf215546Sopenharmony_ci#define __DRI2_FLUSH_CONTROL "DRI_FlushControl"
1804bf215546Sopenharmony_ci#define __DRI2_FLUSH_CONTROL_VERSION 1
1805bf215546Sopenharmony_ci
1806bf215546Sopenharmony_citypedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension;
1807bf215546Sopenharmony_cistruct __DRI2flushControlExtensionRec {
1808bf215546Sopenharmony_ci   __DRIextension base;
1809bf215546Sopenharmony_ci};
1810bf215546Sopenharmony_ci
1811bf215546Sopenharmony_ci/**
1812bf215546Sopenharmony_ci * DRI config options extension.
1813bf215546Sopenharmony_ci *
1814bf215546Sopenharmony_ci * This extension provides the XML string containing driver options for use by
1815bf215546Sopenharmony_ci * the loader in supporting the driconf application.
1816bf215546Sopenharmony_ci *
1817bf215546Sopenharmony_ci * v2:
1818bf215546Sopenharmony_ci * - Add the getXml getter function which allows the driver more flexibility in
1819bf215546Sopenharmony_ci *   how the XML is provided.
1820bf215546Sopenharmony_ci * - Deprecate the direct xml pointer. It is only provided as a fallback for
1821bf215546Sopenharmony_ci *   older versions of libGL and must not be used by clients that are aware of
1822bf215546Sopenharmony_ci *   the newer version. Future driver versions may set it to NULL.
1823bf215546Sopenharmony_ci */
1824bf215546Sopenharmony_ci#define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
1825bf215546Sopenharmony_ci#define __DRI_CONFIG_OPTIONS_VERSION 2
1826bf215546Sopenharmony_ci
1827bf215546Sopenharmony_citypedef struct __DRIconfigOptionsExtensionRec {
1828bf215546Sopenharmony_ci   __DRIextension base;
1829bf215546Sopenharmony_ci   const char *xml; /**< deprecated since v2, use getXml instead */
1830bf215546Sopenharmony_ci
1831bf215546Sopenharmony_ci   /**
1832bf215546Sopenharmony_ci    * Get an XML string that describes available driver options for use by a
1833bf215546Sopenharmony_ci    * config application.
1834bf215546Sopenharmony_ci    *
1835bf215546Sopenharmony_ci    * The returned string must be heap-allocated. The caller is responsible for
1836bf215546Sopenharmony_ci    * freeing it.
1837bf215546Sopenharmony_ci    */
1838bf215546Sopenharmony_ci   char *(*getXml)(const char *driver_name);
1839bf215546Sopenharmony_ci} __DRIconfigOptionsExtension;
1840bf215546Sopenharmony_ci
1841bf215546Sopenharmony_ci/**
1842bf215546Sopenharmony_ci * This extension provides a driver vtable to a set of common driver helper
1843bf215546Sopenharmony_ci * functions (driCoreExtension, driDRI2Extension) within the driver
1844bf215546Sopenharmony_ci * implementation, as opposed to having to pass them through a global
1845bf215546Sopenharmony_ci * variable.
1846bf215546Sopenharmony_ci *
1847bf215546Sopenharmony_ci * It is not intended to be public API to the actual loader, and the vtable
1848bf215546Sopenharmony_ci * layout may change at any time.
1849bf215546Sopenharmony_ci */
1850bf215546Sopenharmony_ci#define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
1851bf215546Sopenharmony_ci#define __DRI_DRIVER_VTABLE_VERSION 1
1852bf215546Sopenharmony_ci
1853bf215546Sopenharmony_citypedef struct __DRIDriverVtableExtensionRec {
1854bf215546Sopenharmony_ci    __DRIextension base;
1855bf215546Sopenharmony_ci    const struct __DriverAPIRec *vtable;
1856bf215546Sopenharmony_ci} __DRIDriverVtableExtension;
1857bf215546Sopenharmony_ci
1858bf215546Sopenharmony_ci/**
1859bf215546Sopenharmony_ci * Query renderer driver extension
1860bf215546Sopenharmony_ci *
1861bf215546Sopenharmony_ci * This allows the window system layer (either EGL or GLX) to query aspects of
1862bf215546Sopenharmony_ci * hardware and driver support without creating a context.
1863bf215546Sopenharmony_ci */
1864bf215546Sopenharmony_ci#define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
1865bf215546Sopenharmony_ci#define __DRI2_RENDERER_QUERY_VERSION 1
1866bf215546Sopenharmony_ci
1867bf215546Sopenharmony_ci#define __DRI2_RENDERER_VENDOR_ID                             0x0000
1868bf215546Sopenharmony_ci#define __DRI2_RENDERER_DEVICE_ID                             0x0001
1869bf215546Sopenharmony_ci#define __DRI2_RENDERER_VERSION                               0x0002
1870bf215546Sopenharmony_ci#define __DRI2_RENDERER_ACCELERATED                           0x0003
1871bf215546Sopenharmony_ci#define __DRI2_RENDERER_VIDEO_MEMORY                          0x0004
1872bf215546Sopenharmony_ci#define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE           0x0005
1873bf215546Sopenharmony_ci#define __DRI2_RENDERER_PREFERRED_PROFILE                     0x0006
1874bf215546Sopenharmony_ci#define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION           0x0007
1875bf215546Sopenharmony_ci#define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION  0x0008
1876bf215546Sopenharmony_ci#define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION             0x0009
1877bf215546Sopenharmony_ci#define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION            0x000a
1878bf215546Sopenharmony_ci#define __DRI2_RENDERER_HAS_TEXTURE_3D                        0x000b
1879bf215546Sopenharmony_ci/* Whether there is an sRGB format support for every supported 32-bit UNORM
1880bf215546Sopenharmony_ci * color format.
1881bf215546Sopenharmony_ci */
1882bf215546Sopenharmony_ci#define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB                  0x000c
1883bf215546Sopenharmony_ci
1884bf215546Sopenharmony_ci/* Bitmaks of supported/available context priorities - must match
1885bf215546Sopenharmony_ci * __EGL_CONTEXT_PRIORITY_LOW_BIT et al
1886bf215546Sopenharmony_ci */
1887bf215546Sopenharmony_ci#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY                  0x000d
1888bf215546Sopenharmony_ci#define   __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW            (1 << 0)
1889bf215546Sopenharmony_ci#define   __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM         (1 << 1)
1890bf215546Sopenharmony_ci#define   __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH           (1 << 2)
1891bf215546Sopenharmony_ci
1892bf215546Sopenharmony_ci#define __DRI2_RENDERER_HAS_PROTECTED_CONTENT                 0x000e
1893bf215546Sopenharmony_ci#define __DRI2_RENDERER_PREFER_BACK_BUFFER_REUSE              0x000f
1894bf215546Sopenharmony_ci#define __DRI2_RENDERER_HAS_NO_ERROR_CONTEXT                  0x0010
1895bf215546Sopenharmony_ci
1896bf215546Sopenharmony_citypedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
1897bf215546Sopenharmony_cistruct __DRI2rendererQueryExtensionRec {
1898bf215546Sopenharmony_ci   __DRIextension base;
1899bf215546Sopenharmony_ci
1900bf215546Sopenharmony_ci   int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
1901bf215546Sopenharmony_ci   int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
1902bf215546Sopenharmony_ci};
1903bf215546Sopenharmony_ci
1904bf215546Sopenharmony_ci/**
1905bf215546Sopenharmony_ci * Image Loader extension. Drivers use this to allocate color buffers
1906bf215546Sopenharmony_ci */
1907bf215546Sopenharmony_ci
1908bf215546Sopenharmony_ci/**
1909bf215546Sopenharmony_ci * See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask.
1910bf215546Sopenharmony_ci */
1911bf215546Sopenharmony_cienum __DRIimageBufferMask {
1912bf215546Sopenharmony_ci   __DRI_IMAGE_BUFFER_BACK = (1 << 0),
1913bf215546Sopenharmony_ci   __DRI_IMAGE_BUFFER_FRONT = (1 << 1),
1914bf215546Sopenharmony_ci
1915bf215546Sopenharmony_ci   /**
1916bf215546Sopenharmony_ci    * A buffer shared between application and compositor. The buffer may be
1917bf215546Sopenharmony_ci    * simultaneously accessed by each.
1918bf215546Sopenharmony_ci    *
1919bf215546Sopenharmony_ci    * A shared buffer is equivalent to an EGLSurface whose EGLConfig contains
1920bf215546Sopenharmony_ci    * EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as
1921bf215546Sopenharmony_ci    * opposed to any pending, requested change to EGL_RENDER_BUFFER) is
1922bf215546Sopenharmony_ci    * EGL_SINGLE_BUFFER.
1923bf215546Sopenharmony_ci    *
1924bf215546Sopenharmony_ci    * If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no
1925bf215546Sopenharmony_ci    * other bits. As a corollary, a __DRIdrawable that has a "shared" buffer
1926bf215546Sopenharmony_ci    * has no front nor back buffer.
1927bf215546Sopenharmony_ci    *
1928bf215546Sopenharmony_ci    * The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only
1929bf215546Sopenharmony_ci    * if:
1930bf215546Sopenharmony_ci    *     - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER.
1931bf215546Sopenharmony_ci    *     - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER.
1932bf215546Sopenharmony_ci    *     - The EGLConfig of the drawable EGLSurface contains
1933bf215546Sopenharmony_ci    *       EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.
1934bf215546Sopenharmony_ci    *     - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER.
1935bf215546Sopenharmony_ci    *       Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as
1936bf215546Sopenharmony_ci    *       opposed to any pending, requested change to EGL_RENDER_BUFFER) is
1937bf215546Sopenharmony_ci    *       EGL_SINGLE_BUFFER. (See the EGL 1.5 and
1938bf215546Sopenharmony_ci    *       EGL_KHR_mutable_render_buffer spec for details about "pending" vs
1939bf215546Sopenharmony_ci    *       "active" EGL_RENDER_BUFFER state).
1940bf215546Sopenharmony_ci    *
1941bf215546Sopenharmony_ci    * A shared buffer is similar to a front buffer in that all rendering to the
1942bf215546Sopenharmony_ci    * buffer should appear promptly on the screen. It is different from
1943bf215546Sopenharmony_ci    * a front buffer in that its behavior is independent from the
1944bf215546Sopenharmony_ci    * GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the
1945bf215546Sopenharmony_ci    * __DRIdrawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all
1946bf215546Sopenharmony_ci    * rendering should appear promptly on the screen if GL_DRAW_BUFFER is not
1947bf215546Sopenharmony_ci    * GL_NONE.
1948bf215546Sopenharmony_ci    *
1949bf215546Sopenharmony_ci    * The difference between a shared buffer and a front buffer is motivated
1950bf215546Sopenharmony_ci    * by the constraints of Android and OpenGL ES. OpenGL ES does not support
1951bf215546Sopenharmony_ci    * front-buffer rendering. Android's SurfaceFlinger protocol provides the
1952bf215546Sopenharmony_ci    * EGL driver only a back buffer and no front buffer. The shared buffer
1953bf215546Sopenharmony_ci    * mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though
1954bf215546Sopenharmony_ci    * EGL that allows Android OpenGL ES applications to render to what is
1955bf215546Sopenharmony_ci    * effectively the front buffer, a backdoor that required no change to the
1956bf215546Sopenharmony_ci    * OpenGL ES API and little change to the SurfaceFlinger API.
1957bf215546Sopenharmony_ci    */
1958bf215546Sopenharmony_ci   __DRI_IMAGE_BUFFER_SHARED = (1 << 2),
1959bf215546Sopenharmony_ci};
1960bf215546Sopenharmony_ci
1961bf215546Sopenharmony_cistruct __DRIimageList {
1962bf215546Sopenharmony_ci   uint32_t image_mask;
1963bf215546Sopenharmony_ci   __DRIimage *back;
1964bf215546Sopenharmony_ci   __DRIimage *front;
1965bf215546Sopenharmony_ci};
1966bf215546Sopenharmony_ci
1967bf215546Sopenharmony_ci#define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
1968bf215546Sopenharmony_ci#define __DRI_IMAGE_LOADER_VERSION 4
1969bf215546Sopenharmony_ci
1970bf215546Sopenharmony_cistruct __DRIimageLoaderExtensionRec {
1971bf215546Sopenharmony_ci    __DRIextension base;
1972bf215546Sopenharmony_ci
1973bf215546Sopenharmony_ci   /**
1974bf215546Sopenharmony_ci    * Allocate color buffers.
1975bf215546Sopenharmony_ci    *
1976bf215546Sopenharmony_ci    * \param driDrawable
1977bf215546Sopenharmony_ci    * \param width              Width of allocated buffers
1978bf215546Sopenharmony_ci    * \param height             Height of allocated buffers
1979bf215546Sopenharmony_ci    * \param format             one of __DRI_IMAGE_FORMAT_*
1980bf215546Sopenharmony_ci    * \param stamp              Address of variable to be updated when
1981bf215546Sopenharmony_ci    *                           getBuffers must be called again
1982bf215546Sopenharmony_ci    * \param loaderPrivate      The loaderPrivate for driDrawable
1983bf215546Sopenharmony_ci    * \param buffer_mask        Set of buffers to allocate. A bitmask of
1984bf215546Sopenharmony_ci    *                           __DRIimageBufferMask.
1985bf215546Sopenharmony_ci    * \param buffers            Returned buffers
1986bf215546Sopenharmony_ci    */
1987bf215546Sopenharmony_ci   int (*getBuffers)(__DRIdrawable *driDrawable,
1988bf215546Sopenharmony_ci                     unsigned int format,
1989bf215546Sopenharmony_ci                     uint32_t *stamp,
1990bf215546Sopenharmony_ci                     void *loaderPrivate,
1991bf215546Sopenharmony_ci                     uint32_t buffer_mask,
1992bf215546Sopenharmony_ci                     struct __DRIimageList *buffers);
1993bf215546Sopenharmony_ci
1994bf215546Sopenharmony_ci    /**
1995bf215546Sopenharmony_ci     * Flush pending front-buffer rendering
1996bf215546Sopenharmony_ci     *
1997bf215546Sopenharmony_ci     * Any rendering that has been performed to the
1998bf215546Sopenharmony_ci     * fake front will be flushed to the front
1999bf215546Sopenharmony_ci     *
2000bf215546Sopenharmony_ci     * \param driDrawable    Drawable whose front-buffer is to be flushed
2001bf215546Sopenharmony_ci     * \param loaderPrivate  Loader's private data that was previously passed
2002bf215546Sopenharmony_ci     *                       into __DRIdri2ExtensionRec::createNewDrawable
2003bf215546Sopenharmony_ci     */
2004bf215546Sopenharmony_ci    void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
2005bf215546Sopenharmony_ci
2006bf215546Sopenharmony_ci    /**
2007bf215546Sopenharmony_ci     * Return a loader capability value. If the loader doesn't know the enum,
2008bf215546Sopenharmony_ci     * it will return 0.
2009bf215546Sopenharmony_ci     *
2010bf215546Sopenharmony_ci     * \since 2
2011bf215546Sopenharmony_ci     */
2012bf215546Sopenharmony_ci    unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
2013bf215546Sopenharmony_ci
2014bf215546Sopenharmony_ci    /**
2015bf215546Sopenharmony_ci     * Flush swap buffers
2016bf215546Sopenharmony_ci     *
2017bf215546Sopenharmony_ci     * Make sure any outstanding swap buffers have been submitted to the
2018bf215546Sopenharmony_ci     * device.
2019bf215546Sopenharmony_ci     *
2020bf215546Sopenharmony_ci     * \param driDrawable    Drawable whose swaps need to be flushed
2021bf215546Sopenharmony_ci     * \param loaderPrivate  Loader's private data that was previously passed
2022bf215546Sopenharmony_ci     *                       into __DRIdri2ExtensionRec::createNewDrawable
2023bf215546Sopenharmony_ci     *
2024bf215546Sopenharmony_ci     * \since 3
2025bf215546Sopenharmony_ci     */
2026bf215546Sopenharmony_ci    void (*flushSwapBuffers)(__DRIdrawable *driDrawable, void *loaderPrivate);
2027bf215546Sopenharmony_ci
2028bf215546Sopenharmony_ci    /**
2029bf215546Sopenharmony_ci     * Clean up any loader state associated with an image.
2030bf215546Sopenharmony_ci     *
2031bf215546Sopenharmony_ci     * \param loaderPrivate  Loader's private data that was previously passed
2032bf215546Sopenharmony_ci     *                       into a __DRIimageExtensionRec::createImage function
2033bf215546Sopenharmony_ci     * \since 4
2034bf215546Sopenharmony_ci     */
2035bf215546Sopenharmony_ci    void (*destroyLoaderImageState)(void *loaderPrivate);
2036bf215546Sopenharmony_ci};
2037bf215546Sopenharmony_ci
2038bf215546Sopenharmony_ci/**
2039bf215546Sopenharmony_ci * DRI extension.
2040bf215546Sopenharmony_ci */
2041bf215546Sopenharmony_ci
2042bf215546Sopenharmony_ci#define __DRI_IMAGE_DRIVER           "DRI_IMAGE_DRIVER"
2043bf215546Sopenharmony_ci#define __DRI_IMAGE_DRIVER_VERSION   1
2044bf215546Sopenharmony_ci
2045bf215546Sopenharmony_cistruct __DRIimageDriverExtensionRec {
2046bf215546Sopenharmony_ci   __DRIextension               base;
2047bf215546Sopenharmony_ci
2048bf215546Sopenharmony_ci   /* Common DRI functions, shared with DRI2 */
2049bf215546Sopenharmony_ci   __DRIcreateNewScreen2Func            createNewScreen2;
2050bf215546Sopenharmony_ci   __DRIcreateNewDrawableFunc           createNewDrawable;
2051bf215546Sopenharmony_ci   __DRIcreateContextAttribsFunc        createContextAttribs;
2052bf215546Sopenharmony_ci   __DRIgetAPIMaskFunc                  getAPIMask;
2053bf215546Sopenharmony_ci};
2054bf215546Sopenharmony_ci
2055bf215546Sopenharmony_ci/**
2056bf215546Sopenharmony_ci * Background callable loader extension.
2057bf215546Sopenharmony_ci *
2058bf215546Sopenharmony_ci * Loaders expose this extension to indicate to drivers that they are capable
2059bf215546Sopenharmony_ci * of handling callbacks from the driver's background drawing threads.
2060bf215546Sopenharmony_ci */
2061bf215546Sopenharmony_ci#define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"
2062bf215546Sopenharmony_ci#define __DRI_BACKGROUND_CALLABLE_VERSION 1
2063bf215546Sopenharmony_ci
2064bf215546Sopenharmony_citypedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension;
2065bf215546Sopenharmony_cistruct __DRIbackgroundCallableExtensionRec {
2066bf215546Sopenharmony_ci   __DRIextension base;
2067bf215546Sopenharmony_ci
2068bf215546Sopenharmony_ci   /**
2069bf215546Sopenharmony_ci    * Indicate that this thread is being used by the driver as a background
2070bf215546Sopenharmony_ci    * drawing thread which may make callbacks to the loader.
2071bf215546Sopenharmony_ci    *
2072bf215546Sopenharmony_ci    * \param loaderPrivate is the value that was passed to to the driver when
2073bf215546Sopenharmony_ci    * the context was created.  This can be used by the loader to identify
2074bf215546Sopenharmony_ci    * which context any callbacks are associated with.
2075bf215546Sopenharmony_ci    *
2076bf215546Sopenharmony_ci    * If this function is called more than once from any given thread, each
2077bf215546Sopenharmony_ci    * subsequent call overrides the loaderPrivate data that was passed in the
2078bf215546Sopenharmony_ci    * previous call.  The driver can take advantage of this to re-use a
2079bf215546Sopenharmony_ci    * background thread to perform drawing on behalf of multiple contexts.
2080bf215546Sopenharmony_ci    *
2081bf215546Sopenharmony_ci    * It is permissible for the driver to call this function from a
2082bf215546Sopenharmony_ci    * non-background thread (i.e. a thread that has already been bound to a
2083bf215546Sopenharmony_ci    * context using __DRIcoreExtensionRec::bindContext()); when this happens,
2084bf215546Sopenharmony_ci    * the \c loaderPrivate pointer must be equal to the pointer that was
2085bf215546Sopenharmony_ci    * passed to the driver when the currently bound context was created.
2086bf215546Sopenharmony_ci    *
2087bf215546Sopenharmony_ci    * This call should execute quickly enough that the driver can call it with
2088bf215546Sopenharmony_ci    * impunity whenever a background thread starts performing drawing
2089bf215546Sopenharmony_ci    * operations (e.g. it should just set a thread-local variable).
2090bf215546Sopenharmony_ci    */
2091bf215546Sopenharmony_ci   void (*setBackgroundContext)(void *loaderPrivate);
2092bf215546Sopenharmony_ci
2093bf215546Sopenharmony_ci   /**
2094bf215546Sopenharmony_ci    * Indicate that it is multithread safe to use glthread.  For GLX/EGL
2095bf215546Sopenharmony_ci    * platforms using Xlib, that involves calling XInitThreads, before
2096bf215546Sopenharmony_ci    * opening an X display.
2097bf215546Sopenharmony_ci    *
2098bf215546Sopenharmony_ci    * Note: only supported if extension version is at least 2.
2099bf215546Sopenharmony_ci    *
2100bf215546Sopenharmony_ci    * \param loaderPrivate is the value that was passed to to the driver when
2101bf215546Sopenharmony_ci    * the context was created.  This can be used by the loader to identify
2102bf215546Sopenharmony_ci    * which context any callbacks are associated with.
2103bf215546Sopenharmony_ci    */
2104bf215546Sopenharmony_ci   unsigned char (*isThreadSafe)(void *loaderPrivate);
2105bf215546Sopenharmony_ci};
2106bf215546Sopenharmony_ci
2107bf215546Sopenharmony_ci/**
2108bf215546Sopenharmony_ci * The driver portion of EGL_KHR_mutable_render_buffer.
2109bf215546Sopenharmony_ci *
2110bf215546Sopenharmony_ci * If the driver creates a __DRIconfig with
2111bf215546Sopenharmony_ci * __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension.
2112bf215546Sopenharmony_ci *
2113bf215546Sopenharmony_ci * To support this extension:
2114bf215546Sopenharmony_ci *
2115bf215546Sopenharmony_ci *    - The driver should create at least one __DRIconfig with
2116bf215546Sopenharmony_ci *      __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but
2117bf215546Sopenharmony_ci *      not required.
2118bf215546Sopenharmony_ci *
2119bf215546Sopenharmony_ci *    - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if
2120bf215546Sopenharmony_ci *      returned by __DRIimageLoaderExtension:getBuffers().
2121bf215546Sopenharmony_ci *
2122bf215546Sopenharmony_ci *    - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call
2123bf215546Sopenharmony_ci *      __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() in
2124bf215546Sopenharmony_ci *      response to glFlush and glFinish.  (This requirement is not documented
2125bf215546Sopenharmony_ci *      in EGL_KHR_mutable_render_buffer, but is a de-facto requirement in the
2126bf215546Sopenharmony_ci *      Android ecosystem. Android applications expect that glFlush will
2127bf215546Sopenharmony_ci *      immediately display the buffer when in shared buffer mode, and Android
2128bf215546Sopenharmony_ci *      drivers comply with this expectation).  It :may: call
2129bf215546Sopenharmony_ci *      displaySharedBuffer() more often than required.
2130bf215546Sopenharmony_ci *
2131bf215546Sopenharmony_ci *    - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the
2132bf215546Sopenharmony_ci *      buffer is always in a format compatible for display because the
2133bf215546Sopenharmony_ci *      display engine (usually SurfaceFlinger or hwcomposer) may display the
2134bf215546Sopenharmony_ci *      image at any time, even concurrently with 3D rendering. For example,
2135bf215546Sopenharmony_ci *      display hardware and the GL hardware may be able to access the buffer
2136bf215546Sopenharmony_ci *      simultaneously. In particular, if the buffer is compressed then take
2137bf215546Sopenharmony_ci *      care that SurfaceFlinger and hwcomposer can consume the compression
2138bf215546Sopenharmony_ci *      format.
2139bf215546Sopenharmony_ci *
2140bf215546Sopenharmony_ci * \see __DRI_IMAGE_BUFFER_SHARED
2141bf215546Sopenharmony_ci * \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER
2142bf215546Sopenharmony_ci * \see __DRI_MUTABLE_RENDER_BUFFER_LOADER
2143bf215546Sopenharmony_ci */
2144bf215546Sopenharmony_ci#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver"
2145bf215546Sopenharmony_ci#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 1
2146bf215546Sopenharmony_ci
2147bf215546Sopenharmony_citypedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension;
2148bf215546Sopenharmony_cistruct __DRImutableRenderBufferDriverExtensionRec {
2149bf215546Sopenharmony_ci   __DRIextension base;
2150bf215546Sopenharmony_ci};
2151bf215546Sopenharmony_ci
2152bf215546Sopenharmony_ci/**
2153bf215546Sopenharmony_ci * The loader portion of EGL_KHR_mutable_render_buffer.
2154bf215546Sopenharmony_ci *
2155bf215546Sopenharmony_ci * Requires loader extension DRI_IMAGE_LOADER, through which the loader sends
2156bf215546Sopenharmony_ci * __DRI_IMAGE_BUFFER_SHARED to the driver.
2157bf215546Sopenharmony_ci *
2158bf215546Sopenharmony_ci * \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER
2159bf215546Sopenharmony_ci */
2160bf215546Sopenharmony_ci#define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader"
2161bf215546Sopenharmony_ci#define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 1
2162bf215546Sopenharmony_ci
2163bf215546Sopenharmony_citypedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension;
2164bf215546Sopenharmony_cistruct __DRImutableRenderBufferLoaderExtensionRec {
2165bf215546Sopenharmony_ci   __DRIextension base;
2166bf215546Sopenharmony_ci
2167bf215546Sopenharmony_ci   /**
2168bf215546Sopenharmony_ci    * Inform the display engine (that is, SurfaceFlinger and/or hwcomposer)
2169bf215546Sopenharmony_ci    * that the __DRIdrawable has new content.
2170bf215546Sopenharmony_ci    *
2171bf215546Sopenharmony_ci    * The display engine may ignore this call, for example, if it continually
2172bf215546Sopenharmony_ci    * refreshes and displays the buffer on every frame, as in
2173bf215546Sopenharmony_ci    * EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display
2174bf215546Sopenharmony_ci    * engine may refresh and display the buffer only in frames in which the
2175bf215546Sopenharmony_ci    * driver calls this.
2176bf215546Sopenharmony_ci    *
2177bf215546Sopenharmony_ci    * If the fence_fd is not -1, then the display engine will display the
2178bf215546Sopenharmony_ci    * buffer only after the fence signals.
2179bf215546Sopenharmony_ci    *
2180bf215546Sopenharmony_ci    * The drawable's current __DRIimageBufferMask, as returned by
2181bf215546Sopenharmony_ci    * __DRIimageLoaderExtension::getBuffers(), must be
2182bf215546Sopenharmony_ci    * __DRI_IMAGE_BUFFER_SHARED.
2183bf215546Sopenharmony_ci    */
2184bf215546Sopenharmony_ci   void (*displaySharedBuffer)(__DRIdrawable *drawable, int fence_fd,
2185bf215546Sopenharmony_ci                               void *loaderPrivate);
2186bf215546Sopenharmony_ci};
2187bf215546Sopenharmony_ci
2188bf215546Sopenharmony_ci#endif
2189