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