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