OSDN Git Service

glx: Drop support for GLX_MESA_allocate_memory
[android-x86/external-mesa.git] / include / GL / internal / dri_interface.h
1 /*
2  * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3  * Copyright 2007-2008 Red Hat, Inc.
4  * (C) Copyright IBM Corporation 2004
5  * All Rights Reserved.
6  *
7  * Permission is hereby granted, free of charge, to any person obtaining a
8  * copy of this software and associated documentation files (the "Software"),
9  * to deal in the Software without restriction, including without limitation
10  * on the rights to use, copy, modify, merge, publish, distribute, sub
11  * license, and/or sell copies of the Software, and to permit persons to whom
12  * the Software is furnished to do so, subject to the following conditions:
13  *
14  * The above copyright notice and this permission notice (including the next
15  * paragraph) shall be included in all copies or substantial portions of the
16  * Software.
17  *
18  * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19  * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20  * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT.  IN NO EVENT SHALL
21  * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22  * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23  * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24  * USE OR OTHER DEALINGS IN THE SOFTWARE.
25  */
26
27 /**
28  * \file dri_interface.h
29  *
30  * This file contains all the types and functions that define the interface
31  * between a DRI driver and driver loader.  Currently, the most common driver
32  * loader is the XFree86 libGL.so.  However, other loaders do exist, and in
33  * the future the server-side libglx.a will also be a loader.
34  * 
35  * \author Kevin E. Martin <kevin@precisioninsight.com>
36  * \author Ian Romanick <idr@us.ibm.com>
37  * \author Kristian Høgsberg <krh@redhat.com>
38  */
39
40 #ifndef DRI_INTERFACE_H
41 #define DRI_INTERFACE_H
42
43 /* For archs with no drm.h */
44 #if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__)
45 #ifndef __NOT_HAVE_DRM_H
46 #define __NOT_HAVE_DRM_H
47 #endif
48 #endif
49
50 #ifndef __NOT_HAVE_DRM_H
51 #include <drm.h>
52 #else
53 typedef unsigned int drm_context_t;
54 typedef unsigned int drm_drawable_t;
55 typedef struct drm_clip_rect drm_clip_rect_t;
56 #endif
57
58 /**
59  * \name DRI interface structures
60  *
61  * The following structures define the interface between the GLX client
62  * side library and the DRI (direct rendering infrastructure).
63  */
64 /*@{*/
65 typedef struct __DRIdisplayRec          __DRIdisplay;
66 typedef struct __DRIscreenRec           __DRIscreen;
67 typedef struct __DRIcontextRec          __DRIcontext;
68 typedef struct __DRIdrawableRec         __DRIdrawable;
69 typedef struct __DRIconfigRec           __DRIconfig;
70 typedef struct __DRIframebufferRec      __DRIframebuffer;
71 typedef struct __DRIversionRec          __DRIversion;
72
73 typedef struct __DRIcoreExtensionRec            __DRIcoreExtension;
74 typedef struct __DRIextensionRec                __DRIextension;
75 typedef struct __DRIcopySubBufferExtensionRec   __DRIcopySubBufferExtension;
76 typedef struct __DRIswapControlExtensionRec     __DRIswapControlExtension;
77 typedef struct __DRIframeTrackingExtensionRec   __DRIframeTrackingExtension;
78 typedef struct __DRImediaStreamCounterExtensionRec      __DRImediaStreamCounterExtension;
79 typedef struct __DRItexOffsetExtensionRec       __DRItexOffsetExtension;
80 typedef struct __DRItexBufferExtensionRec       __DRItexBufferExtension;
81 typedef struct __DRIlegacyExtensionRec          __DRIlegacyExtension;
82 typedef struct __DRIswrastExtensionRec          __DRIswrastExtension;
83 typedef struct __DRIbufferRec                   __DRIbuffer;
84 typedef struct __DRIdri2ExtensionRec            __DRIdri2Extension;
85 typedef struct __DRIdri2LoaderExtensionRec      __DRIdri2LoaderExtension;
86 typedef struct __DRI2flushExtensionRec  __DRI2flushExtension;
87
88 /*@}*/
89
90
91 /**
92  * Extension struct.  Drivers 'inherit' from this struct by embedding
93  * it as the first element in the extension struct.
94  *
95  * We never break API in for a DRI extension.  If we need to change
96  * the way things work in a non-backwards compatible manner, we
97  * introduce a new extension.  During a transition period, we can
98  * leave both the old and the new extension in the driver, which
99  * allows us to move to the new interface without having to update the
100  * loader(s) in lock step.
101  *
102  * However, we can add entry points to an extension over time as long
103  * as we don't break the old ones.  As we add entry points to an
104  * extension, we increase the version number.  The corresponding
105  * #define can be used to guard code that accesses the new entry
106  * points at compile time and the version field in the extension
107  * struct can be used at run-time to determine how to use the
108  * extension.
109  */
110 struct __DRIextensionRec {
111     const char *name;
112     int version;
113 };
114
115 /**
116  * The first set of extension are the screen extensions, returned by
117  * __DRIcore::getExtensions().  This entry point will return a list of
118  * extensions and the loader can use the ones it knows about by
119  * casting them to more specific extensions and advertising any GLX
120  * extensions the DRI extensions enables.
121  */
122
123 /**
124  * Used by drivers to indicate support for setting the read drawable.
125  */
126 #define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
127 #define __DRI_READ_DRAWABLE_VERSION 1
128
129 /**
130  * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
131  */
132 #define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
133 #define __DRI_COPY_SUB_BUFFER_VERSION 1
134 struct __DRIcopySubBufferExtensionRec {
135     __DRIextension base;
136     void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);
137 };
138
139 /**
140  * Used by drivers that implement the GLX_SGI_swap_control or
141  * GLX_MESA_swap_control extension.
142  */
143 #define __DRI_SWAP_CONTROL "DRI_SwapControl"
144 #define __DRI_SWAP_CONTROL_VERSION 1
145 struct __DRIswapControlExtensionRec {
146     __DRIextension base;
147     void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
148     unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
149 };
150
151 /**
152  * Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
153  */
154 #define __DRI_FRAME_TRACKING "DRI_FrameTracking"
155 #define __DRI_FRAME_TRACKING_VERSION 1
156 struct __DRIframeTrackingExtensionRec {
157     __DRIextension base;
158
159     /**
160      * Enable or disable frame usage tracking.
161      * 
162      * \since Internal API version 20030317.
163      */
164     int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable);
165
166     /**
167      * Retrieve frame usage information.
168      * 
169      * \since Internal API version 20030317.
170      */
171     int (*queryFrameTracking)(__DRIdrawable *drawable,
172                               int64_t * sbc, int64_t * missedFrames,
173                               float * lastMissedUsage, float * usage);
174 };
175
176
177 /**
178  * Used by drivers that implement the GLX_SGI_video_sync extension.
179  */
180 #define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
181 #define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
182 struct __DRImediaStreamCounterExtensionRec {
183     __DRIextension base;
184
185     /**
186      * Wait for the MSC to equal target_msc, or, if that has already passed,
187      * the next time (MSC % divisor) is equal to remainder.  If divisor is
188      * zero, the function will return as soon as MSC is greater than or equal
189      * to target_msc.
190      */
191     int (*waitForMSC)(__DRIdrawable *drawable,
192                       int64_t target_msc, int64_t divisor, int64_t remainder,
193                       int64_t * msc, int64_t * sbc);
194
195     /**
196      * Get the number of vertical refreshes since some point in time before
197      * this function was first called (i.e., system start up).
198      */
199     int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
200                           int64_t *msc);
201 };
202
203
204 #define __DRI_TEX_OFFSET "DRI_TexOffset"
205 #define __DRI_TEX_OFFSET_VERSION 1
206 struct __DRItexOffsetExtensionRec {
207     __DRIextension base;
208
209     /**
210      * Method to override base texture image with a driver specific 'offset'.
211      * The depth passed in allows e.g. to ignore the alpha channel of texture
212      * images where the non-alpha components don't occupy a whole texel.
213      *
214      * For GLX_EXT_texture_from_pixmap with AIGLX.
215      */
216     void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
217                          unsigned long long offset, GLint depth, GLuint pitch);
218 };
219
220
221 /* Valid values for format in the setTexBuffer2 function below.  These
222  * values match the GLX tokens for compatibility reasons, but we
223  * define them here since the DRI interface can't depend on GLX. */
224 #define __DRI_TEXTURE_FORMAT_NONE        0x20D8
225 #define __DRI_TEXTURE_FORMAT_RGB         0x20D9
226 #define __DRI_TEXTURE_FORMAT_RGBA        0x20DA
227
228 #define __DRI_TEX_BUFFER "DRI_TexBuffer"
229 #define __DRI_TEX_BUFFER_VERSION 2
230 struct __DRItexBufferExtensionRec {
231     __DRIextension base;
232
233     /**
234      * Method to override base texture image with the contents of a
235      * __DRIdrawable. 
236      *
237      * For GLX_EXT_texture_from_pixmap with AIGLX.  Deprecated in favor of
238      * setTexBuffer2 in version 2 of this interface
239      */
240     void (*setTexBuffer)(__DRIcontext *pDRICtx,
241                          GLint target,
242                          __DRIdrawable *pDraw);
243
244     /**
245      * Method to override base texture image with the contents of a
246      * __DRIdrawable, including the required texture format attribute.
247      *
248      * For GLX_EXT_texture_from_pixmap with AIGLX.
249      */
250     void (*setTexBuffer2)(__DRIcontext *pDRICtx,
251                           GLint target,
252                           GLint format,
253                           __DRIdrawable *pDraw);
254 };
255
256 /**
257  * Used by drivers that implement DRI2
258  */
259 #define __DRI2_FLUSH "DRI2_Flush"
260 #define __DRI2_FLUSH_VERSION 3
261 struct __DRI2flushExtensionRec {
262     __DRIextension base;
263     void (*flush)(__DRIdrawable *drawable);
264
265     /**
266      * Ask the driver to call getBuffers/getBuffersWithFormat before
267      * it starts rendering again.
268      *
269      * \param drawable the drawable to invalidate
270      *
271      * \since 3
272      */
273     void (*invalidate)(__DRIdrawable *drawable);
274 };
275
276
277 /**
278  * XML document describing the configuration options supported by the
279  * driver.
280  */
281 extern const char __driConfigOptions[];
282
283 /*@}*/
284
285 /**
286  * The following extensions describe loader features that the DRI
287  * driver can make use of.  Some of these are mandatory, such as the
288  * getDrawableInfo extension for DRI and the DRI Loader extensions for
289  * DRI2, while others are optional, and if present allow the driver to
290  * expose certain features.  The loader pass in a NULL terminated
291  * array of these extensions to the driver in the createNewScreen
292  * constructor.
293  */
294
295 typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
296 typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
297 typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
298 typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
299 typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
300
301
302 /**
303  * Callback to getDrawableInfo protocol
304  */
305 #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
306 #define __DRI_GET_DRAWABLE_INFO_VERSION 1
307 struct __DRIgetDrawableInfoExtensionRec {
308     __DRIextension base;
309
310     /**
311      * This function is used to get information about the position, size, and
312      * clip rects of a drawable.
313      */
314     GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
315         unsigned int * index, unsigned int * stamp,
316         int * x, int * y, int * width, int * height,
317         int * numClipRects, drm_clip_rect_t ** pClipRects,
318         int * backX, int * backY,
319         int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
320         void *loaderPrivate);
321 };
322
323 /**
324  * Callback to get system time for media stream counter extensions.
325  */
326 #define __DRI_SYSTEM_TIME "DRI_SystemTime"
327 #define __DRI_SYSTEM_TIME_VERSION 1
328 struct __DRIsystemTimeExtensionRec {
329     __DRIextension base;
330
331     /**
332      * Get the 64-bit unadjusted system time (UST).
333      */
334     int (*getUST)(int64_t * ust);
335
336     /**
337      * Get the media stream counter (MSC) rate.
338      * 
339      * Matching the definition in GLX_OML_sync_control, this function returns
340      * the rate of the "media stream counter".  In practical terms, this is
341      * the frame refresh rate of the display.
342      */
343     GLboolean (*getMSCRate)(__DRIdrawable *draw,
344                             int32_t * numerator, int32_t * denominator,
345                             void *loaderPrivate);
346 };
347
348 /**
349  * Damage reporting
350  */
351 #define __DRI_DAMAGE "DRI_Damage"
352 #define __DRI_DAMAGE_VERSION 1
353 struct __DRIdamageExtensionRec {
354     __DRIextension base;
355
356     /**
357      * Reports areas of the given drawable which have been modified by the
358      * driver.
359      *
360      * \param drawable which the drawing was done to.
361      * \param rects rectangles affected, with the drawable origin as the
362      *        origin.
363      * \param x X offset of the drawable within the screen (used in the
364      *        front_buffer case)
365      * \param y Y offset of the drawable within the screen.
366      * \param front_buffer boolean flag for whether the drawing to the
367      *        drawable was actually done directly to the front buffer (instead
368      *        of backing storage, for example)
369      * \param loaderPrivate the data passed in at createNewDrawable time
370      */
371     void (*reportDamage)(__DRIdrawable *draw,
372                          int x, int y,
373                          drm_clip_rect_t *rects, int num_rects,
374                          GLboolean front_buffer,
375                          void *loaderPrivate);
376 };
377
378 #define __DRI_SWRAST_IMAGE_OP_DRAW      1
379 #define __DRI_SWRAST_IMAGE_OP_CLEAR     2
380 #define __DRI_SWRAST_IMAGE_OP_SWAP      3
381
382 /**
383  * SWRast Loader extension.
384  */
385 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
386 #define __DRI_SWRAST_LOADER_VERSION 1
387 struct __DRIswrastLoaderExtensionRec {
388     __DRIextension base;
389
390     /*
391      * Drawable position and size
392      */
393     void (*getDrawableInfo)(__DRIdrawable *drawable,
394                             int *x, int *y, int *width, int *height,
395                             void *loaderPrivate);
396
397     /**
398      * Put image to drawable
399      */
400     void (*putImage)(__DRIdrawable *drawable, int op,
401                      int x, int y, int width, int height,
402                      char *data, void *loaderPrivate);
403
404     /**
405      * Get image from readable
406      */
407     void (*getImage)(__DRIdrawable *readable,
408                      int x, int y, int width, int height,
409                      char *data, void *loaderPrivate);
410 };
411
412 /**
413  * Invalidate loader extension.  The presence of this extension
414  * indicates to the DRI driver that the loader will call invalidate in
415  * the __DRI2_FLUSH extension, whenever the needs to query for new
416  * buffers.  This means that the DRI driver can drop the polling in
417  * glViewport().
418  *
419  * The extension doesn't provide any functionality, it's only use to
420  * indicate to the driver that it can use the new semantics.  A DRI
421  * driver can use this to switch between the different semantics or
422  * just refuse to initialize if this extension isn't present.
423  */
424 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
425 #define __DRI_USE_INVALIDATE_VERSION 1
426
427 typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
428 struct __DRIuseInvalidateExtensionRec {
429    __DRIextension base;
430 };
431
432 /**
433  * The remaining extensions describe driver extensions, immediately
434  * available interfaces provided by the driver.  To start using the
435  * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
436  * the extension you need in the array.
437  */
438 #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
439
440 /**
441  * Tokens for __DRIconfig attribs.  A number of attributes defined by
442  * GLX or EGL standards are not in the table, as they must be provided
443  * by the loader.  For example, FBConfig ID or visual ID, drawable type.
444  */
445
446 #define __DRI_ATTRIB_BUFFER_SIZE                 1
447 #define __DRI_ATTRIB_LEVEL                       2
448 #define __DRI_ATTRIB_RED_SIZE                    3
449 #define __DRI_ATTRIB_GREEN_SIZE                  4
450 #define __DRI_ATTRIB_BLUE_SIZE                   5
451 #define __DRI_ATTRIB_LUMINANCE_SIZE              6
452 #define __DRI_ATTRIB_ALPHA_SIZE                  7
453 #define __DRI_ATTRIB_ALPHA_MASK_SIZE             8
454 #define __DRI_ATTRIB_DEPTH_SIZE                  9
455 #define __DRI_ATTRIB_STENCIL_SIZE               10
456 #define __DRI_ATTRIB_ACCUM_RED_SIZE             11
457 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE           12
458 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE            13
459 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE           14
460 #define __DRI_ATTRIB_SAMPLE_BUFFERS             15
461 #define __DRI_ATTRIB_SAMPLES                    16
462 #define __DRI_ATTRIB_RENDER_TYPE                17
463 #define __DRI_ATTRIB_CONFIG_CAVEAT              18
464 #define __DRI_ATTRIB_CONFORMANT                 19
465 #define __DRI_ATTRIB_DOUBLE_BUFFER              20
466 #define __DRI_ATTRIB_STEREO                     21
467 #define __DRI_ATTRIB_AUX_BUFFERS                22
468 #define __DRI_ATTRIB_TRANSPARENT_TYPE           23
469 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE    24
470 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE      25
471 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE    26
472 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE     27
473 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE    28
474 #define __DRI_ATTRIB_FLOAT_MODE                 29
475 #define __DRI_ATTRIB_RED_MASK                   30
476 #define __DRI_ATTRIB_GREEN_MASK                 31
477 #define __DRI_ATTRIB_BLUE_MASK                  32
478 #define __DRI_ATTRIB_ALPHA_MASK                 33
479 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH          34
480 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT         35
481 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS         36
482 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH      37
483 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT     38
484 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP        39
485 #define __DRI_ATTRIB_SWAP_METHOD                40
486 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL          41
487 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL          42
488 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB        43
489 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA       44
490 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE     45
491 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS    46
492 #define __DRI_ATTRIB_YINVERTED                  47
493
494 /* __DRI_ATTRIB_RENDER_TYPE */
495 #define __DRI_ATTRIB_RGBA_BIT                   0x01    
496 #define __DRI_ATTRIB_COLOR_INDEX_BIT            0x02
497 #define __DRI_ATTRIB_LUMINANCE_BIT              0x04
498
499 /* __DRI_ATTRIB_CONFIG_CAVEAT */
500 #define __DRI_ATTRIB_SLOW_BIT                   0x01
501 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG      0x02
502
503 /* __DRI_ATTRIB_TRANSPARENT_TYPE */
504 #define __DRI_ATTRIB_TRANSPARENT_RGB            0x00
505 #define __DRI_ATTRIB_TRANSPARENT_INDEX          0x01
506
507 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS  */
508 #define __DRI_ATTRIB_TEXTURE_1D_BIT             0x01
509 #define __DRI_ATTRIB_TEXTURE_2D_BIT             0x02
510 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT      0x04
511
512 /**
513  * This extension defines the core DRI functionality.
514  */
515 #define __DRI_CORE "DRI_Core"
516 #define __DRI_CORE_VERSION 1
517
518 struct __DRIcoreExtensionRec {
519     __DRIextension base;
520
521     __DRIscreen *(*createNewScreen)(int screen, int fd,
522                                     unsigned int sarea_handle,
523                                     const __DRIextension **extensions,
524                                     const __DRIconfig ***driverConfigs,
525                                     void *loaderPrivate);
526
527     void (*destroyScreen)(__DRIscreen *screen);
528
529     const __DRIextension **(*getExtensions)(__DRIscreen *screen);
530
531     int (*getConfigAttrib)(const __DRIconfig *config,
532                            unsigned int attrib,
533                            unsigned int *value);
534
535     int (*indexConfigAttrib)(const __DRIconfig *config, int index,
536                              unsigned int *attrib, unsigned int *value);
537
538     __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
539                                         const __DRIconfig *config,
540                                         unsigned int drawable_id,
541                                         unsigned int head,
542                                         void *loaderPrivate);
543
544     void (*destroyDrawable)(__DRIdrawable *drawable);
545
546     void (*swapBuffers)(__DRIdrawable *drawable);
547
548     __DRIcontext *(*createNewContext)(__DRIscreen *screen,
549                                       const __DRIconfig *config,
550                                       __DRIcontext *shared,
551                                       void *loaderPrivate);
552
553     int (*copyContext)(__DRIcontext *dest,
554                        __DRIcontext *src,
555                        unsigned long mask);
556
557     void (*destroyContext)(__DRIcontext *context);
558
559     int (*bindContext)(__DRIcontext *ctx,
560                        __DRIdrawable *pdraw,
561                        __DRIdrawable *pread);
562
563     int (*unbindContext)(__DRIcontext *ctx);
564 };
565
566 /**
567  * Stored version of some component (i.e., server-side DRI module, kernel-side
568  * DRM, etc.).
569  * 
570  * \todo
571  * There are several data structures that explicitly store a major version,
572  * minor version, and patch level.  These structures should be modified to
573  * have a \c __DRIversionRec instead.
574  */
575 struct __DRIversionRec {
576     int    major;        /**< Major version number. */
577     int    minor;        /**< Minor version number. */
578     int    patch;        /**< Patch-level. */
579 };
580
581 /**
582  * Framebuffer information record.  Used by libGL to communicate information
583  * about the framebuffer to the driver's \c __driCreateNewScreen function.
584  * 
585  * In XFree86, most of this information is derrived from data returned by
586  * calling \c XF86DRIGetDeviceInfo.
587  *
588  * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
589  *     __driUtilCreateNewScreen CallCreateNewScreen
590  *
591  * \bug This structure could be better named.
592  */
593 struct __DRIframebufferRec {
594     unsigned char *base;    /**< Framebuffer base address in the CPU's
595                              * address space.  This value is calculated by
596                              * calling \c drmMap on the framebuffer handle
597                              * returned by \c XF86DRIGetDeviceInfo (or a
598                              * similar function).
599                              */
600     int size;               /**< Framebuffer size, in bytes. */
601     int stride;             /**< Number of bytes from one line to the next. */
602     int width;              /**< Pixel width of the framebuffer. */
603     int height;             /**< Pixel height of the framebuffer. */
604     int dev_priv_size;      /**< Size of the driver's dev-priv structure. */
605     void *dev_priv;         /**< Pointer to the driver's dev-priv structure. */
606 };
607
608
609 /**
610  * This extension provides alternative screen, drawable and context
611  * constructors for legacy DRI functionality.  This is used in
612  * conjunction with the core extension.
613  */
614 #define __DRI_LEGACY "DRI_Legacy"
615 #define __DRI_LEGACY_VERSION 1
616
617 struct __DRIlegacyExtensionRec {
618     __DRIextension base;
619
620     __DRIscreen *(*createNewScreen)(int screen,
621                                     const __DRIversion *ddx_version,
622                                     const __DRIversion *dri_version,
623                                     const __DRIversion *drm_version,
624                                     const __DRIframebuffer *frame_buffer,
625                                     void *pSAREA, int fd, 
626                                     const __DRIextension **extensions,
627                                     const __DRIconfig ***driver_configs,
628                                     void *loaderPrivate);
629
630     __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
631                                         const __DRIconfig *config,
632                                         drm_drawable_t hwDrawable,
633                                         int renderType, const int *attrs,
634                                         void *loaderPrivate);
635
636     __DRIcontext *(*createNewContext)(__DRIscreen *screen,
637                                       const __DRIconfig *config,
638                                       int render_type,
639                                       __DRIcontext *shared,
640                                       drm_context_t hwContext,
641                                       void *loaderPrivate);
642 };
643
644 /**
645  * This extension provides alternative screen, drawable and context
646  * constructors for swrast DRI functionality.  This is used in
647  * conjunction with the core extension.
648  */
649 #define __DRI_SWRAST "DRI_SWRast"
650 #define __DRI_SWRAST_VERSION 1
651
652 struct __DRIswrastExtensionRec {
653     __DRIextension base;
654
655     __DRIscreen *(*createNewScreen)(int screen,
656                                     const __DRIextension **extensions,
657                                     const __DRIconfig ***driver_configs,
658                                     void *loaderPrivate);
659
660     __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
661                                         const __DRIconfig *config,
662                                         void *loaderPrivate);
663 };
664
665 /**
666  * DRI2 Loader extension.
667  */
668 #define __DRI_BUFFER_FRONT_LEFT         0
669 #define __DRI_BUFFER_BACK_LEFT          1
670 #define __DRI_BUFFER_FRONT_RIGHT        2
671 #define __DRI_BUFFER_BACK_RIGHT         3
672 #define __DRI_BUFFER_DEPTH              4
673 #define __DRI_BUFFER_STENCIL            5
674 #define __DRI_BUFFER_ACCUM              6
675 #define __DRI_BUFFER_FAKE_FRONT_LEFT    7
676 #define __DRI_BUFFER_FAKE_FRONT_RIGHT   8
677 #define __DRI_BUFFER_DEPTH_STENCIL      9  /**< Only available with DRI2 1.1 */
678
679 struct __DRIbufferRec {
680     unsigned int attachment;
681     unsigned int name;
682     unsigned int pitch;
683     unsigned int cpp;
684     unsigned int flags;
685 };
686
687 #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
688 #define __DRI_DRI2_LOADER_VERSION 3
689 struct __DRIdri2LoaderExtensionRec {
690     __DRIextension base;
691
692     __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
693                                int *width, int *height,
694                                unsigned int *attachments, int count,
695                                int *out_count, void *loaderPrivate);
696
697     /**
698      * Flush pending front-buffer rendering
699      *
700      * Any rendering that has been performed to the
701      * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
702      * \c __DRI_BUFFER_FRONT_LEFT.
703      *
704      * \param driDrawable    Drawable whose front-buffer is to be flushed
705      * \param loaderPrivate  Loader's private data that was previously passed
706      *                       into __DRIdri2ExtensionRec::createNewDrawable
707      */
708     void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
709
710
711     /**
712      * Get list of buffers from the server
713      *
714      * Gets a list of buffer for the specified set of attachments.  Unlike
715      * \c ::getBuffers, this function takes a list of attachments paired with
716      * opaque \c unsigned \c int value describing the format of the buffer.
717      * It is the responsibility of the caller to know what the service that
718      * allocates the buffers will expect to receive for the format.
719      *
720      * \param driDrawable    Drawable whose buffers are being queried.
721      * \param width          Output where the width of the buffers is stored.
722      * \param height         Output where the height of the buffers is stored.
723      * \param attachments    List of pairs of attachment ID and opaque format
724      *                       requested for the drawable.
725      * \param count          Number of attachment / format pairs stored in
726      *                       \c attachments.
727      * \param loaderPrivate  Loader's private data that was previously passed
728      *                       into __DRIdri2ExtensionRec::createNewDrawable.
729      */
730     __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
731                                          int *width, int *height,
732                                          unsigned int *attachments, int count,
733                                          int *out_count, void *loaderPrivate);
734 };
735
736 /**
737  * This extension provides alternative screen, drawable and context
738  * constructors for DRI2.
739  */
740 #define __DRI_DRI2 "DRI_DRI2"
741 #define __DRI_DRI2_VERSION 2
742
743 #define __DRI_API_OPENGL        0
744 #define __DRI_API_GLES          1
745 #define __DRI_API_GLES2         2
746
747 struct __DRIdri2ExtensionRec {
748     __DRIextension base;
749
750     __DRIscreen *(*createNewScreen)(int screen, int fd,
751                                     const __DRIextension **extensions,
752                                     const __DRIconfig ***driver_configs,
753                                     void *loaderPrivate);
754
755     __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
756                                         const __DRIconfig *config,
757                                         void *loaderPrivate);
758
759     __DRIcontext *(*createNewContext)(__DRIscreen *screen,
760                                       const __DRIconfig *config,
761                                       __DRIcontext *shared,
762                                       void *loaderPrivate);
763
764    /* Since version 2 */
765    unsigned int (*getAPIMask)(__DRIscreen *screen);
766
767    __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
768                                            int api,
769                                            const __DRIconfig *config,
770                                            __DRIcontext *shared,
771                                            void *data);
772 };
773
774
775 /**
776  * This extension provides functionality to enable various EGLImage
777  * extensions.
778  */
779 #define __DRI_IMAGE "DRI_IMAGE"
780 #define __DRI_IMAGE_VERSION 1
781
782 /**
783  * These formats correspond to the similarly named MESA_FORMAT_*
784  * tokens, except in the native endian of the CPU.  For example, on
785  * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
786  * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
787  */
788 #define __DRI_IMAGE_FORMAT_RGB565       0x1001
789 #define __DRI_IMAGE_FORMAT_XRGB8888     0x1002
790 #define __DRI_IMAGE_FORMAT_ARGB8888     0x1003
791
792 typedef struct __DRIimageRec          __DRIimage;
793 typedef struct __DRIimageExtensionRec __DRIimageExtension;
794 struct __DRIimageExtensionRec {
795     __DRIextension base;
796
797     __DRIimage *(*createImageFromName)(__DRIcontext *context,
798                                        int width, int height, int format,
799                                        int name, int pitch,
800                                        void *loaderPrivate);
801
802     __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
803                                                int renderbuffer,
804                                                void *loaderPrivate);
805
806     void (*destroyImage)(__DRIimage *image);
807 };
808
809 /**
810  * This extension must be implemented by the loader and passed to the
811  * driver at screen creation time.  The EGLImage entry points in the
812  * various client APIs take opaque EGLImage handles and use this
813  * extension to map them to a __DRIimage.  At version 1, this
814  * extensions allows mapping EGLImage pointers to __DRIimage pointers,
815  * but future versions could support other EGLImage-like, opaque types
816  * with new lookup functions.
817  */
818 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
819 #define __DRI_IMAGE_LOOKUP_VERSION 1
820
821 typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
822 struct __DRIimageLookupExtensionRec {
823     __DRIextension base;
824
825     __DRIimage *(*lookupEGLImage)(__DRIcontext *context, void *image,
826                                   void *loaderPrivate);
827 };
828
829 /**
830  * This extension allows for common DRI2 options
831  */
832 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
833 #define __DRI2_CONFIG_QUERY_VERSION 1
834
835 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
836 struct __DRI2configQueryExtensionRec {
837    __DRIextension base;
838
839    int (*configQueryb)(__DRIscreen *screen, const char *var, GLboolean *val);
840    int (*configQueryi)(__DRIscreen *screen, const char *var, GLint *val);
841    int (*configQueryf)(__DRIscreen *screen, const char *var, GLfloat *val);
842 };
843 #endif