Merge branch 'master' of git://anongit.freedesktop.org/mesa/mesa
[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 * Method to release texture buffer in case some special platform
256 * need this.
257 *
258 * For GLX_EXT_texture_from_pixmap with AIGLX.
259 */
260 void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
261 GLint target,
262 __DRIdrawable *pDraw);
263 };
264
265 /**
266 * Used by drivers that implement DRI2
267 */
268 #define __DRI2_FLUSH "DRI2_Flush"
269 #define __DRI2_FLUSH_VERSION 3
270 struct __DRI2flushExtensionRec {
271 __DRIextension base;
272 void (*flush)(__DRIdrawable *drawable);
273
274 /**
275 * Ask the driver to call getBuffers/getBuffersWithFormat before
276 * it starts rendering again.
277 *
278 * \param drawable the drawable to invalidate
279 *
280 * \since 3
281 */
282 void (*invalidate)(__DRIdrawable *drawable);
283 };
284
285
286 /**
287 * XML document describing the configuration options supported by the
288 * driver.
289 */
290 extern const char __driConfigOptions[];
291
292 /*@}*/
293
294 /**
295 * The following extensions describe loader features that the DRI
296 * driver can make use of. Some of these are mandatory, such as the
297 * getDrawableInfo extension for DRI and the DRI Loader extensions for
298 * DRI2, while others are optional, and if present allow the driver to
299 * expose certain features. The loader pass in a NULL terminated
300 * array of these extensions to the driver in the createNewScreen
301 * constructor.
302 */
303
304 typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
305 typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
306 typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
307 typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
308 typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
309
310
311 /**
312 * Callback to getDrawableInfo protocol
313 */
314 #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
315 #define __DRI_GET_DRAWABLE_INFO_VERSION 1
316 struct __DRIgetDrawableInfoExtensionRec {
317 __DRIextension base;
318
319 /**
320 * This function is used to get information about the position, size, and
321 * clip rects of a drawable.
322 */
323 GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
324 unsigned int * index, unsigned int * stamp,
325 int * x, int * y, int * width, int * height,
326 int * numClipRects, drm_clip_rect_t ** pClipRects,
327 int * backX, int * backY,
328 int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
329 void *loaderPrivate);
330 };
331
332 /**
333 * Callback to get system time for media stream counter extensions.
334 */
335 #define __DRI_SYSTEM_TIME "DRI_SystemTime"
336 #define __DRI_SYSTEM_TIME_VERSION 1
337 struct __DRIsystemTimeExtensionRec {
338 __DRIextension base;
339
340 /**
341 * Get the 64-bit unadjusted system time (UST).
342 */
343 int (*getUST)(int64_t * ust);
344
345 /**
346 * Get the media stream counter (MSC) rate.
347 *
348 * Matching the definition in GLX_OML_sync_control, this function returns
349 * the rate of the "media stream counter". In practical terms, this is
350 * the frame refresh rate of the display.
351 */
352 GLboolean (*getMSCRate)(__DRIdrawable *draw,
353 int32_t * numerator, int32_t * denominator,
354 void *loaderPrivate);
355 };
356
357 /**
358 * Damage reporting
359 */
360 #define __DRI_DAMAGE "DRI_Damage"
361 #define __DRI_DAMAGE_VERSION 1
362 struct __DRIdamageExtensionRec {
363 __DRIextension base;
364
365 /**
366 * Reports areas of the given drawable which have been modified by the
367 * driver.
368 *
369 * \param drawable which the drawing was done to.
370 * \param rects rectangles affected, with the drawable origin as the
371 * origin.
372 * \param x X offset of the drawable within the screen (used in the
373 * front_buffer case)
374 * \param y Y offset of the drawable within the screen.
375 * \param front_buffer boolean flag for whether the drawing to the
376 * drawable was actually done directly to the front buffer (instead
377 * of backing storage, for example)
378 * \param loaderPrivate the data passed in at createNewDrawable time
379 */
380 void (*reportDamage)(__DRIdrawable *draw,
381 int x, int y,
382 drm_clip_rect_t *rects, int num_rects,
383 GLboolean front_buffer,
384 void *loaderPrivate);
385 };
386
387 #define __DRI_SWRAST_IMAGE_OP_DRAW 1
388 #define __DRI_SWRAST_IMAGE_OP_CLEAR 2
389 #define __DRI_SWRAST_IMAGE_OP_SWAP 3
390
391 /**
392 * SWRast Loader extension.
393 */
394 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
395 #define __DRI_SWRAST_LOADER_VERSION 1
396 struct __DRIswrastLoaderExtensionRec {
397 __DRIextension base;
398
399 /*
400 * Drawable position and size
401 */
402 void (*getDrawableInfo)(__DRIdrawable *drawable,
403 int *x, int *y, int *width, int *height,
404 void *loaderPrivate);
405
406 /**
407 * Put image to drawable
408 */
409 void (*putImage)(__DRIdrawable *drawable, int op,
410 int x, int y, int width, int height,
411 char *data, void *loaderPrivate);
412
413 /**
414 * Get image from readable
415 */
416 void (*getImage)(__DRIdrawable *readable,
417 int x, int y, int width, int height,
418 char *data, void *loaderPrivate);
419 };
420
421 /**
422 * Invalidate loader extension. The presence of this extension
423 * indicates to the DRI driver that the loader will call invalidate in
424 * the __DRI2_FLUSH extension, whenever the needs to query for new
425 * buffers. This means that the DRI driver can drop the polling in
426 * glViewport().
427 *
428 * The extension doesn't provide any functionality, it's only use to
429 * indicate to the driver that it can use the new semantics. A DRI
430 * driver can use this to switch between the different semantics or
431 * just refuse to initialize if this extension isn't present.
432 */
433 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
434 #define __DRI_USE_INVALIDATE_VERSION 1
435
436 typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
437 struct __DRIuseInvalidateExtensionRec {
438 __DRIextension base;
439 };
440
441 /**
442 * The remaining extensions describe driver extensions, immediately
443 * available interfaces provided by the driver. To start using the
444 * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
445 * the extension you need in the array.
446 */
447 #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
448
449 /**
450 * Tokens for __DRIconfig attribs. A number of attributes defined by
451 * GLX or EGL standards are not in the table, as they must be provided
452 * by the loader. For example, FBConfig ID or visual ID, drawable type.
453 */
454
455 #define __DRI_ATTRIB_BUFFER_SIZE 1
456 #define __DRI_ATTRIB_LEVEL 2
457 #define __DRI_ATTRIB_RED_SIZE 3
458 #define __DRI_ATTRIB_GREEN_SIZE 4
459 #define __DRI_ATTRIB_BLUE_SIZE 5
460 #define __DRI_ATTRIB_LUMINANCE_SIZE 6
461 #define __DRI_ATTRIB_ALPHA_SIZE 7
462 #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
463 #define __DRI_ATTRIB_DEPTH_SIZE 9
464 #define __DRI_ATTRIB_STENCIL_SIZE 10
465 #define __DRI_ATTRIB_ACCUM_RED_SIZE 11
466 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
467 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
468 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
469 #define __DRI_ATTRIB_SAMPLE_BUFFERS 15
470 #define __DRI_ATTRIB_SAMPLES 16
471 #define __DRI_ATTRIB_RENDER_TYPE 17
472 #define __DRI_ATTRIB_CONFIG_CAVEAT 18
473 #define __DRI_ATTRIB_CONFORMANT 19
474 #define __DRI_ATTRIB_DOUBLE_BUFFER 20
475 #define __DRI_ATTRIB_STEREO 21
476 #define __DRI_ATTRIB_AUX_BUFFERS 22
477 #define __DRI_ATTRIB_TRANSPARENT_TYPE 23
478 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
479 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
480 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
481 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
482 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
483 #define __DRI_ATTRIB_FLOAT_MODE 29
484 #define __DRI_ATTRIB_RED_MASK 30
485 #define __DRI_ATTRIB_GREEN_MASK 31
486 #define __DRI_ATTRIB_BLUE_MASK 32
487 #define __DRI_ATTRIB_ALPHA_MASK 33
488 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
489 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
490 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
491 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
492 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
493 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
494 #define __DRI_ATTRIB_SWAP_METHOD 40
495 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
496 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
497 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
498 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
499 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
500 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
501 #define __DRI_ATTRIB_YINVERTED 47
502 #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
503
504 /* __DRI_ATTRIB_RENDER_TYPE */
505 #define __DRI_ATTRIB_RGBA_BIT 0x01
506 #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
507 #define __DRI_ATTRIB_LUMINANCE_BIT 0x04
508
509 /* __DRI_ATTRIB_CONFIG_CAVEAT */
510 #define __DRI_ATTRIB_SLOW_BIT 0x01
511 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
512
513 /* __DRI_ATTRIB_TRANSPARENT_TYPE */
514 #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
515 #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
516
517 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
518 #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
519 #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
520 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
521
522 /**
523 * This extension defines the core DRI functionality.
524 */
525 #define __DRI_CORE "DRI_Core"
526 #define __DRI_CORE_VERSION 1
527
528 struct __DRIcoreExtensionRec {
529 __DRIextension base;
530
531 __DRIscreen *(*createNewScreen)(int screen, int fd,
532 unsigned int sarea_handle,
533 const __DRIextension **extensions,
534 const __DRIconfig ***driverConfigs,
535 void *loaderPrivate);
536
537 void (*destroyScreen)(__DRIscreen *screen);
538
539 const __DRIextension **(*getExtensions)(__DRIscreen *screen);
540
541 int (*getConfigAttrib)(const __DRIconfig *config,
542 unsigned int attrib,
543 unsigned int *value);
544
545 int (*indexConfigAttrib)(const __DRIconfig *config, int index,
546 unsigned int *attrib, unsigned int *value);
547
548 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
549 const __DRIconfig *config,
550 unsigned int drawable_id,
551 unsigned int head,
552 void *loaderPrivate);
553
554 void (*destroyDrawable)(__DRIdrawable *drawable);
555
556 void (*swapBuffers)(__DRIdrawable *drawable);
557
558 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
559 const __DRIconfig *config,
560 __DRIcontext *shared,
561 void *loaderPrivate);
562
563 int (*copyContext)(__DRIcontext *dest,
564 __DRIcontext *src,
565 unsigned long mask);
566
567 void (*destroyContext)(__DRIcontext *context);
568
569 int (*bindContext)(__DRIcontext *ctx,
570 __DRIdrawable *pdraw,
571 __DRIdrawable *pread);
572
573 int (*unbindContext)(__DRIcontext *ctx);
574 };
575
576 /**
577 * Stored version of some component (i.e., server-side DRI module, kernel-side
578 * DRM, etc.).
579 *
580 * \todo
581 * There are several data structures that explicitly store a major version,
582 * minor version, and patch level. These structures should be modified to
583 * have a \c __DRIversionRec instead.
584 */
585 struct __DRIversionRec {
586 int major; /**< Major version number. */
587 int minor; /**< Minor version number. */
588 int patch; /**< Patch-level. */
589 };
590
591 /**
592 * Framebuffer information record. Used by libGL to communicate information
593 * about the framebuffer to the driver's \c __driCreateNewScreen function.
594 *
595 * In XFree86, most of this information is derrived from data returned by
596 * calling \c XF86DRIGetDeviceInfo.
597 *
598 * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
599 * __driUtilCreateNewScreen CallCreateNewScreen
600 *
601 * \bug This structure could be better named.
602 */
603 struct __DRIframebufferRec {
604 unsigned char *base; /**< Framebuffer base address in the CPU's
605 * address space. This value is calculated by
606 * calling \c drmMap on the framebuffer handle
607 * returned by \c XF86DRIGetDeviceInfo (or a
608 * similar function).
609 */
610 int size; /**< Framebuffer size, in bytes. */
611 int stride; /**< Number of bytes from one line to the next. */
612 int width; /**< Pixel width of the framebuffer. */
613 int height; /**< Pixel height of the framebuffer. */
614 int dev_priv_size; /**< Size of the driver's dev-priv structure. */
615 void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
616 };
617
618
619 /**
620 * This extension provides alternative screen, drawable and context
621 * constructors for legacy DRI functionality. This is used in
622 * conjunction with the core extension.
623 */
624 #define __DRI_LEGACY "DRI_Legacy"
625 #define __DRI_LEGACY_VERSION 1
626
627 struct __DRIlegacyExtensionRec {
628 __DRIextension base;
629
630 __DRIscreen *(*createNewScreen)(int screen,
631 const __DRIversion *ddx_version,
632 const __DRIversion *dri_version,
633 const __DRIversion *drm_version,
634 const __DRIframebuffer *frame_buffer,
635 void *pSAREA, int fd,
636 const __DRIextension **extensions,
637 const __DRIconfig ***driver_configs,
638 void *loaderPrivate);
639
640 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
641 const __DRIconfig *config,
642 drm_drawable_t hwDrawable,
643 int renderType, const int *attrs,
644 void *loaderPrivate);
645
646 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
647 const __DRIconfig *config,
648 int render_type,
649 __DRIcontext *shared,
650 drm_context_t hwContext,
651 void *loaderPrivate);
652 };
653
654 /**
655 * This extension provides alternative screen, drawable and context
656 * constructors for swrast DRI functionality. This is used in
657 * conjunction with the core extension.
658 */
659 #define __DRI_SWRAST "DRI_SWRast"
660 #define __DRI_SWRAST_VERSION 2
661
662 struct __DRIswrastExtensionRec {
663 __DRIextension base;
664
665 __DRIscreen *(*createNewScreen)(int screen,
666 const __DRIextension **extensions,
667 const __DRIconfig ***driver_configs,
668 void *loaderPrivate);
669
670 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
671 const __DRIconfig *config,
672 void *loaderPrivate);
673
674 /* Since version 2 */
675 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
676 int api,
677 const __DRIconfig *config,
678 __DRIcontext *shared,
679 void *data);
680 };
681
682 /**
683 * DRI2 Loader extension.
684 */
685 #define __DRI_BUFFER_FRONT_LEFT 0
686 #define __DRI_BUFFER_BACK_LEFT 1
687 #define __DRI_BUFFER_FRONT_RIGHT 2
688 #define __DRI_BUFFER_BACK_RIGHT 3
689 #define __DRI_BUFFER_DEPTH 4
690 #define __DRI_BUFFER_STENCIL 5
691 #define __DRI_BUFFER_ACCUM 6
692 #define __DRI_BUFFER_FAKE_FRONT_LEFT 7
693 #define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
694 #define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
695 #define __DRI_BUFFER_HIZ 10
696
697 /* Inofficial and for internal use. Increase when adding a new buffer token. */
698 #define __DRI_BUFFER_COUNT 11
699
700 struct __DRIbufferRec {
701 unsigned int attachment;
702 unsigned int name;
703 unsigned int pitch;
704 unsigned int cpp;
705 unsigned int flags;
706 };
707
708 #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
709 #define __DRI_DRI2_LOADER_VERSION 3
710 struct __DRIdri2LoaderExtensionRec {
711 __DRIextension base;
712
713 __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
714 int *width, int *height,
715 unsigned int *attachments, int count,
716 int *out_count, void *loaderPrivate);
717
718 /**
719 * Flush pending front-buffer rendering
720 *
721 * Any rendering that has been performed to the
722 * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
723 * \c __DRI_BUFFER_FRONT_LEFT.
724 *
725 * \param driDrawable Drawable whose front-buffer is to be flushed
726 * \param loaderPrivate Loader's private data that was previously passed
727 * into __DRIdri2ExtensionRec::createNewDrawable
728 */
729 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
730
731
732 /**
733 * Get list of buffers from the server
734 *
735 * Gets a list of buffer for the specified set of attachments. Unlike
736 * \c ::getBuffers, this function takes a list of attachments paired with
737 * opaque \c unsigned \c int value describing the format of the buffer.
738 * It is the responsibility of the caller to know what the service that
739 * allocates the buffers will expect to receive for the format.
740 *
741 * \param driDrawable Drawable whose buffers are being queried.
742 * \param width Output where the width of the buffers is stored.
743 * \param height Output where the height of the buffers is stored.
744 * \param attachments List of pairs of attachment ID and opaque format
745 * requested for the drawable.
746 * \param count Number of attachment / format pairs stored in
747 * \c attachments.
748 * \param loaderPrivate Loader's private data that was previously passed
749 * into __DRIdri2ExtensionRec::createNewDrawable.
750 */
751 __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
752 int *width, int *height,
753 unsigned int *attachments, int count,
754 int *out_count, void *loaderPrivate);
755 };
756
757 /**
758 * This extension provides alternative screen, drawable and context
759 * constructors for DRI2.
760 */
761 #define __DRI_DRI2 "DRI_DRI2"
762 #define __DRI_DRI2_VERSION 2
763
764 #define __DRI_API_OPENGL 0
765 #define __DRI_API_GLES 1
766 #define __DRI_API_GLES2 2
767
768 struct __DRIdri2ExtensionRec {
769 __DRIextension base;
770
771 __DRIscreen *(*createNewScreen)(int screen, int fd,
772 const __DRIextension **extensions,
773 const __DRIconfig ***driver_configs,
774 void *loaderPrivate);
775
776 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
777 const __DRIconfig *config,
778 void *loaderPrivate);
779
780 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
781 const __DRIconfig *config,
782 __DRIcontext *shared,
783 void *loaderPrivate);
784
785 /* Since version 2 */
786 unsigned int (*getAPIMask)(__DRIscreen *screen);
787
788 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
789 int api,
790 const __DRIconfig *config,
791 __DRIcontext *shared,
792 void *data);
793
794 __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
795 unsigned int attachment,
796 unsigned int format,
797 int width,
798 int height);
799 void (*releaseBuffer)(__DRIscreen *screen,
800 __DRIbuffer *buffer);
801 };
802
803
804 /**
805 * This extension provides functionality to enable various EGLImage
806 * extensions.
807 */
808 #define __DRI_IMAGE "DRI_IMAGE"
809 #define __DRI_IMAGE_VERSION 1
810
811 /**
812 * These formats correspond to the similarly named MESA_FORMAT_*
813 * tokens, except in the native endian of the CPU. For example, on
814 * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
815 * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
816 */
817 #define __DRI_IMAGE_FORMAT_RGB565 0x1001
818 #define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
819 #define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
820
821 #define __DRI_IMAGE_USE_SHARE 0x0001
822 #define __DRI_IMAGE_USE_SCANOUT 0x0002
823 #define __DRI_IMAGE_USE_CURSOR 0x0004
824
825 /**
826 * queryImage attributes
827 */
828
829 #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
830 #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
831 #define __DRI_IMAGE_ATTRIB_NAME 0x2002
832
833 typedef struct __DRIimageRec __DRIimage;
834 typedef struct __DRIimageExtensionRec __DRIimageExtension;
835 struct __DRIimageExtensionRec {
836 __DRIextension base;
837
838 __DRIimage *(*createImageFromName)(__DRIscreen *screen,
839 int width, int height, int format,
840 int name, int pitch,
841 void *loaderPrivate);
842
843 __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
844 int renderbuffer,
845 void *loaderPrivate);
846
847 void (*destroyImage)(__DRIimage *image);
848
849 __DRIimage *(*createImage)(__DRIscreen *screen,
850 int width, int height, int format,
851 unsigned int use,
852 void *loaderPrivate);
853
854 GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
855
856 /**
857 * The new __DRIimage will share the content with the old one, see dup(2).
858 */
859 __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
860 };
861
862
863 /**
864 * This extension must be implemented by the loader and passed to the
865 * driver at screen creation time. The EGLImage entry points in the
866 * various client APIs take opaque EGLImage handles and use this
867 * extension to map them to a __DRIimage. At version 1, this
868 * extensions allows mapping EGLImage pointers to __DRIimage pointers,
869 * but future versions could support other EGLImage-like, opaque types
870 * with new lookup functions.
871 */
872 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
873 #define __DRI_IMAGE_LOOKUP_VERSION 1
874
875 typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
876 struct __DRIimageLookupExtensionRec {
877 __DRIextension base;
878
879 __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
880 void *loaderPrivate);
881 };
882
883 /**
884 * This extension allows for common DRI2 options
885 */
886 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
887 #define __DRI2_CONFIG_QUERY_VERSION 1
888
889 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
890 struct __DRI2configQueryExtensionRec {
891 __DRIextension base;
892
893 int (*configQueryb)(__DRIscreen *screen, const char *var, GLboolean *val);
894 int (*configQueryi)(__DRIscreen *screen, const char *var, GLint *val);
895 int (*configQueryf)(__DRIscreen *screen, const char *var, GLfloat *val);
896 };
897 #endif