gbm: Add gbm_bo_write entry point
[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 typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension;
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_swap_frame_usage extension.
154 */
155 #define __DRI_FRAME_TRACKING "DRI_FrameTracking"
156 #define __DRI_FRAME_TRACKING_VERSION 1
157 struct __DRIframeTrackingExtensionRec {
158 __DRIextension base;
159
160 /**
161 * Enable or disable frame usage tracking.
162 *
163 * \since Internal API version 20030317.
164 */
165 int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable);
166
167 /**
168 * Retrieve frame usage information.
169 *
170 * \since Internal API version 20030317.
171 */
172 int (*queryFrameTracking)(__DRIdrawable *drawable,
173 int64_t * sbc, int64_t * missedFrames,
174 float * lastMissedUsage, float * usage);
175 };
176
177
178 /**
179 * Used by drivers that implement the GLX_SGI_video_sync extension.
180 */
181 #define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
182 #define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
183 struct __DRImediaStreamCounterExtensionRec {
184 __DRIextension base;
185
186 /**
187 * Wait for the MSC to equal target_msc, or, if that has already passed,
188 * the next time (MSC % divisor) is equal to remainder. If divisor is
189 * zero, the function will return as soon as MSC is greater than or equal
190 * to target_msc.
191 */
192 int (*waitForMSC)(__DRIdrawable *drawable,
193 int64_t target_msc, int64_t divisor, int64_t remainder,
194 int64_t * msc, int64_t * sbc);
195
196 /**
197 * Get the number of vertical refreshes since some point in time before
198 * this function was first called (i.e., system start up).
199 */
200 int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
201 int64_t *msc);
202 };
203
204
205 #define __DRI_TEX_OFFSET "DRI_TexOffset"
206 #define __DRI_TEX_OFFSET_VERSION 1
207 struct __DRItexOffsetExtensionRec {
208 __DRIextension base;
209
210 /**
211 * Method to override base texture image with a driver specific 'offset'.
212 * The depth passed in allows e.g. to ignore the alpha channel of texture
213 * images where the non-alpha components don't occupy a whole texel.
214 *
215 * For GLX_EXT_texture_from_pixmap with AIGLX.
216 */
217 void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
218 unsigned long long offset, GLint depth, GLuint pitch);
219 };
220
221
222 /* Valid values for format in the setTexBuffer2 function below. These
223 * values match the GLX tokens for compatibility reasons, but we
224 * define them here since the DRI interface can't depend on GLX. */
225 #define __DRI_TEXTURE_FORMAT_NONE 0x20D8
226 #define __DRI_TEXTURE_FORMAT_RGB 0x20D9
227 #define __DRI_TEXTURE_FORMAT_RGBA 0x20DA
228
229 #define __DRI_TEX_BUFFER "DRI_TexBuffer"
230 #define __DRI_TEX_BUFFER_VERSION 2
231 struct __DRItexBufferExtensionRec {
232 __DRIextension base;
233
234 /**
235 * Method to override base texture image with the contents of a
236 * __DRIdrawable.
237 *
238 * For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of
239 * setTexBuffer2 in version 2 of this interface
240 */
241 void (*setTexBuffer)(__DRIcontext *pDRICtx,
242 GLint target,
243 __DRIdrawable *pDraw);
244
245 /**
246 * Method to override base texture image with the contents of a
247 * __DRIdrawable, including the required texture format attribute.
248 *
249 * For GLX_EXT_texture_from_pixmap with AIGLX.
250 */
251 void (*setTexBuffer2)(__DRIcontext *pDRICtx,
252 GLint target,
253 GLint format,
254 __DRIdrawable *pDraw);
255 /**
256 * Method to release texture buffer in case some special platform
257 * need this.
258 *
259 * For GLX_EXT_texture_from_pixmap with AIGLX.
260 */
261 void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
262 GLint target,
263 __DRIdrawable *pDraw);
264 };
265
266 /**
267 * Used by drivers that implement DRI2
268 */
269 #define __DRI2_FLUSH "DRI2_Flush"
270 #define __DRI2_FLUSH_VERSION 3
271 struct __DRI2flushExtensionRec {
272 __DRIextension base;
273 void (*flush)(__DRIdrawable *drawable);
274
275 /**
276 * Ask the driver to call getBuffers/getBuffersWithFormat before
277 * it starts rendering again.
278 *
279 * \param drawable the drawable to invalidate
280 *
281 * \since 3
282 */
283 void (*invalidate)(__DRIdrawable *drawable);
284 };
285
286
287 /**
288 * Extension that the driver uses to request
289 * throttle callbacks.
290 */
291
292 #define __DRI2_THROTTLE "DRI2_Throttle"
293 #define __DRI2_THROTTLE_VERSION 1
294
295 enum __DRI2throttleReason {
296 __DRI2_THROTTLE_SWAPBUFFER,
297 __DRI2_THROTTLE_COPYSUBBUFFER,
298 __DRI2_THROTTLE_FLUSHFRONT
299 };
300
301 struct __DRI2throttleExtensionRec {
302 __DRIextension base;
303 void (*throttle)(__DRIcontext *ctx,
304 __DRIdrawable *drawable,
305 enum __DRI2throttleReason reason);
306 };
307
308 /**
309 * XML document describing the configuration options supported by the
310 * driver.
311 */
312 extern const char __driConfigOptions[];
313
314 /*@}*/
315
316 /**
317 * The following extensions describe loader features that the DRI
318 * driver can make use of. Some of these are mandatory, such as the
319 * getDrawableInfo extension for DRI and the DRI Loader extensions for
320 * DRI2, while others are optional, and if present allow the driver to
321 * expose certain features. The loader pass in a NULL terminated
322 * array of these extensions to the driver in the createNewScreen
323 * constructor.
324 */
325
326 typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
327 typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
328 typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
329 typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
330 typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
331
332
333 /**
334 * Callback to getDrawableInfo protocol
335 */
336 #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
337 #define __DRI_GET_DRAWABLE_INFO_VERSION 1
338 struct __DRIgetDrawableInfoExtensionRec {
339 __DRIextension base;
340
341 /**
342 * This function is used to get information about the position, size, and
343 * clip rects of a drawable.
344 */
345 GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
346 unsigned int * index, unsigned int * stamp,
347 int * x, int * y, int * width, int * height,
348 int * numClipRects, drm_clip_rect_t ** pClipRects,
349 int * backX, int * backY,
350 int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
351 void *loaderPrivate);
352 };
353
354 /**
355 * Callback to get system time for media stream counter extensions.
356 */
357 #define __DRI_SYSTEM_TIME "DRI_SystemTime"
358 #define __DRI_SYSTEM_TIME_VERSION 1
359 struct __DRIsystemTimeExtensionRec {
360 __DRIextension base;
361
362 /**
363 * Get the 64-bit unadjusted system time (UST).
364 */
365 int (*getUST)(int64_t * ust);
366
367 /**
368 * Get the media stream counter (MSC) rate.
369 *
370 * Matching the definition in GLX_OML_sync_control, this function returns
371 * the rate of the "media stream counter". In practical terms, this is
372 * the frame refresh rate of the display.
373 */
374 GLboolean (*getMSCRate)(__DRIdrawable *draw,
375 int32_t * numerator, int32_t * denominator,
376 void *loaderPrivate);
377 };
378
379 /**
380 * Damage reporting
381 */
382 #define __DRI_DAMAGE "DRI_Damage"
383 #define __DRI_DAMAGE_VERSION 1
384 struct __DRIdamageExtensionRec {
385 __DRIextension base;
386
387 /**
388 * Reports areas of the given drawable which have been modified by the
389 * driver.
390 *
391 * \param drawable which the drawing was done to.
392 * \param rects rectangles affected, with the drawable origin as the
393 * origin.
394 * \param x X offset of the drawable within the screen (used in the
395 * front_buffer case)
396 * \param y Y offset of the drawable within the screen.
397 * \param front_buffer boolean flag for whether the drawing to the
398 * drawable was actually done directly to the front buffer (instead
399 * of backing storage, for example)
400 * \param loaderPrivate the data passed in at createNewDrawable time
401 */
402 void (*reportDamage)(__DRIdrawable *draw,
403 int x, int y,
404 drm_clip_rect_t *rects, int num_rects,
405 GLboolean front_buffer,
406 void *loaderPrivate);
407 };
408
409 #define __DRI_SWRAST_IMAGE_OP_DRAW 1
410 #define __DRI_SWRAST_IMAGE_OP_CLEAR 2
411 #define __DRI_SWRAST_IMAGE_OP_SWAP 3
412
413 /**
414 * SWRast Loader extension.
415 */
416 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
417 #define __DRI_SWRAST_LOADER_VERSION 1
418 struct __DRIswrastLoaderExtensionRec {
419 __DRIextension base;
420
421 /*
422 * Drawable position and size
423 */
424 void (*getDrawableInfo)(__DRIdrawable *drawable,
425 int *x, int *y, int *width, int *height,
426 void *loaderPrivate);
427
428 /**
429 * Put image to drawable
430 */
431 void (*putImage)(__DRIdrawable *drawable, int op,
432 int x, int y, int width, int height,
433 char *data, void *loaderPrivate);
434
435 /**
436 * Get image from readable
437 */
438 void (*getImage)(__DRIdrawable *readable,
439 int x, int y, int width, int height,
440 char *data, void *loaderPrivate);
441 };
442
443 /**
444 * Invalidate loader extension. The presence of this extension
445 * indicates to the DRI driver that the loader will call invalidate in
446 * the __DRI2_FLUSH extension, whenever the needs to query for new
447 * buffers. This means that the DRI driver can drop the polling in
448 * glViewport().
449 *
450 * The extension doesn't provide any functionality, it's only use to
451 * indicate to the driver that it can use the new semantics. A DRI
452 * driver can use this to switch between the different semantics or
453 * just refuse to initialize if this extension isn't present.
454 */
455 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
456 #define __DRI_USE_INVALIDATE_VERSION 1
457
458 typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
459 struct __DRIuseInvalidateExtensionRec {
460 __DRIextension base;
461 };
462
463 /**
464 * The remaining extensions describe driver extensions, immediately
465 * available interfaces provided by the driver. To start using the
466 * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
467 * the extension you need in the array.
468 */
469 #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
470
471 /**
472 * Tokens for __DRIconfig attribs. A number of attributes defined by
473 * GLX or EGL standards are not in the table, as they must be provided
474 * by the loader. For example, FBConfig ID or visual ID, drawable type.
475 */
476
477 #define __DRI_ATTRIB_BUFFER_SIZE 1
478 #define __DRI_ATTRIB_LEVEL 2
479 #define __DRI_ATTRIB_RED_SIZE 3
480 #define __DRI_ATTRIB_GREEN_SIZE 4
481 #define __DRI_ATTRIB_BLUE_SIZE 5
482 #define __DRI_ATTRIB_LUMINANCE_SIZE 6
483 #define __DRI_ATTRIB_ALPHA_SIZE 7
484 #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
485 #define __DRI_ATTRIB_DEPTH_SIZE 9
486 #define __DRI_ATTRIB_STENCIL_SIZE 10
487 #define __DRI_ATTRIB_ACCUM_RED_SIZE 11
488 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
489 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
490 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
491 #define __DRI_ATTRIB_SAMPLE_BUFFERS 15
492 #define __DRI_ATTRIB_SAMPLES 16
493 #define __DRI_ATTRIB_RENDER_TYPE 17
494 #define __DRI_ATTRIB_CONFIG_CAVEAT 18
495 #define __DRI_ATTRIB_CONFORMANT 19
496 #define __DRI_ATTRIB_DOUBLE_BUFFER 20
497 #define __DRI_ATTRIB_STEREO 21
498 #define __DRI_ATTRIB_AUX_BUFFERS 22
499 #define __DRI_ATTRIB_TRANSPARENT_TYPE 23
500 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
501 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
502 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
503 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
504 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
505 #define __DRI_ATTRIB_FLOAT_MODE 29
506 #define __DRI_ATTRIB_RED_MASK 30
507 #define __DRI_ATTRIB_GREEN_MASK 31
508 #define __DRI_ATTRIB_BLUE_MASK 32
509 #define __DRI_ATTRIB_ALPHA_MASK 33
510 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
511 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
512 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
513 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
514 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
515 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
516 #define __DRI_ATTRIB_SWAP_METHOD 40
517 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
518 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
519 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
520 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
521 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
522 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
523 #define __DRI_ATTRIB_YINVERTED 47
524 #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
525
526 /* __DRI_ATTRIB_RENDER_TYPE */
527 #define __DRI_ATTRIB_RGBA_BIT 0x01
528 #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
529 #define __DRI_ATTRIB_LUMINANCE_BIT 0x04
530
531 /* __DRI_ATTRIB_CONFIG_CAVEAT */
532 #define __DRI_ATTRIB_SLOW_BIT 0x01
533 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
534
535 /* __DRI_ATTRIB_TRANSPARENT_TYPE */
536 #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
537 #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
538
539 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
540 #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
541 #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
542 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
543
544 /**
545 * This extension defines the core DRI functionality.
546 */
547 #define __DRI_CORE "DRI_Core"
548 #define __DRI_CORE_VERSION 1
549
550 struct __DRIcoreExtensionRec {
551 __DRIextension base;
552
553 __DRIscreen *(*createNewScreen)(int screen, int fd,
554 unsigned int sarea_handle,
555 const __DRIextension **extensions,
556 const __DRIconfig ***driverConfigs,
557 void *loaderPrivate);
558
559 void (*destroyScreen)(__DRIscreen *screen);
560
561 const __DRIextension **(*getExtensions)(__DRIscreen *screen);
562
563 int (*getConfigAttrib)(const __DRIconfig *config,
564 unsigned int attrib,
565 unsigned int *value);
566
567 int (*indexConfigAttrib)(const __DRIconfig *config, int index,
568 unsigned int *attrib, unsigned int *value);
569
570 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
571 const __DRIconfig *config,
572 unsigned int drawable_id,
573 unsigned int head,
574 void *loaderPrivate);
575
576 void (*destroyDrawable)(__DRIdrawable *drawable);
577
578 void (*swapBuffers)(__DRIdrawable *drawable);
579
580 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
581 const __DRIconfig *config,
582 __DRIcontext *shared,
583 void *loaderPrivate);
584
585 int (*copyContext)(__DRIcontext *dest,
586 __DRIcontext *src,
587 unsigned long mask);
588
589 void (*destroyContext)(__DRIcontext *context);
590
591 int (*bindContext)(__DRIcontext *ctx,
592 __DRIdrawable *pdraw,
593 __DRIdrawable *pread);
594
595 int (*unbindContext)(__DRIcontext *ctx);
596 };
597
598 /**
599 * Stored version of some component (i.e., server-side DRI module, kernel-side
600 * DRM, etc.).
601 *
602 * \todo
603 * There are several data structures that explicitly store a major version,
604 * minor version, and patch level. These structures should be modified to
605 * have a \c __DRIversionRec instead.
606 */
607 struct __DRIversionRec {
608 int major; /**< Major version number. */
609 int minor; /**< Minor version number. */
610 int patch; /**< Patch-level. */
611 };
612
613 /**
614 * Framebuffer information record. Used by libGL to communicate information
615 * about the framebuffer to the driver's \c __driCreateNewScreen function.
616 *
617 * In XFree86, most of this information is derrived from data returned by
618 * calling \c XF86DRIGetDeviceInfo.
619 *
620 * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
621 * __driUtilCreateNewScreen CallCreateNewScreen
622 *
623 * \bug This structure could be better named.
624 */
625 struct __DRIframebufferRec {
626 unsigned char *base; /**< Framebuffer base address in the CPU's
627 * address space. This value is calculated by
628 * calling \c drmMap on the framebuffer handle
629 * returned by \c XF86DRIGetDeviceInfo (or a
630 * similar function).
631 */
632 int size; /**< Framebuffer size, in bytes. */
633 int stride; /**< Number of bytes from one line to the next. */
634 int width; /**< Pixel width of the framebuffer. */
635 int height; /**< Pixel height of the framebuffer. */
636 int dev_priv_size; /**< Size of the driver's dev-priv structure. */
637 void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
638 };
639
640
641 /**
642 * This extension provides alternative screen, drawable and context
643 * constructors for legacy DRI functionality. This is used in
644 * conjunction with the core extension.
645 */
646 #define __DRI_LEGACY "DRI_Legacy"
647 #define __DRI_LEGACY_VERSION 1
648
649 struct __DRIlegacyExtensionRec {
650 __DRIextension base;
651
652 __DRIscreen *(*createNewScreen)(int screen,
653 const __DRIversion *ddx_version,
654 const __DRIversion *dri_version,
655 const __DRIversion *drm_version,
656 const __DRIframebuffer *frame_buffer,
657 void *pSAREA, int fd,
658 const __DRIextension **extensions,
659 const __DRIconfig ***driver_configs,
660 void *loaderPrivate);
661
662 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
663 const __DRIconfig *config,
664 drm_drawable_t hwDrawable,
665 int renderType, const int *attrs,
666 void *loaderPrivate);
667
668 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
669 const __DRIconfig *config,
670 int render_type,
671 __DRIcontext *shared,
672 drm_context_t hwContext,
673 void *loaderPrivate);
674 };
675
676 /**
677 * This extension provides alternative screen, drawable and context
678 * constructors for swrast DRI functionality. This is used in
679 * conjunction with the core extension.
680 */
681 #define __DRI_SWRAST "DRI_SWRast"
682 #define __DRI_SWRAST_VERSION 3
683
684 struct __DRIswrastExtensionRec {
685 __DRIextension base;
686
687 __DRIscreen *(*createNewScreen)(int screen,
688 const __DRIextension **extensions,
689 const __DRIconfig ***driver_configs,
690 void *loaderPrivate);
691
692 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
693 const __DRIconfig *config,
694 void *loaderPrivate);
695
696 /* Since version 2 */
697 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
698 int api,
699 const __DRIconfig *config,
700 __DRIcontext *shared,
701 void *data);
702
703 /**
704 * Create a context for a particular API with a set of attributes
705 *
706 * \since version 3
707 *
708 * \sa __DRIdri2ExtensionRec::createContextAttribs
709 */
710 __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
711 int api,
712 const __DRIconfig *config,
713 __DRIcontext *shared,
714 unsigned num_attribs,
715 const uint32_t *attribs,
716 unsigned *error,
717 void *loaderPrivate);
718 };
719
720 /**
721 * DRI2 Loader extension.
722 */
723 #define __DRI_BUFFER_FRONT_LEFT 0
724 #define __DRI_BUFFER_BACK_LEFT 1
725 #define __DRI_BUFFER_FRONT_RIGHT 2
726 #define __DRI_BUFFER_BACK_RIGHT 3
727 #define __DRI_BUFFER_DEPTH 4
728 #define __DRI_BUFFER_STENCIL 5
729 #define __DRI_BUFFER_ACCUM 6
730 #define __DRI_BUFFER_FAKE_FRONT_LEFT 7
731 #define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
732 #define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
733 #define __DRI_BUFFER_HIZ 10
734
735 /* Inofficial and for internal use. Increase when adding a new buffer token. */
736 #define __DRI_BUFFER_COUNT 11
737
738 struct __DRIbufferRec {
739 unsigned int attachment;
740 unsigned int name;
741 unsigned int pitch;
742 unsigned int cpp;
743 unsigned int flags;
744 };
745
746 #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
747 #define __DRI_DRI2_LOADER_VERSION 3
748 struct __DRIdri2LoaderExtensionRec {
749 __DRIextension base;
750
751 __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
752 int *width, int *height,
753 unsigned int *attachments, int count,
754 int *out_count, void *loaderPrivate);
755
756 /**
757 * Flush pending front-buffer rendering
758 *
759 * Any rendering that has been performed to the
760 * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
761 * \c __DRI_BUFFER_FRONT_LEFT.
762 *
763 * \param driDrawable Drawable whose front-buffer is to be flushed
764 * \param loaderPrivate Loader's private data that was previously passed
765 * into __DRIdri2ExtensionRec::createNewDrawable
766 */
767 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
768
769
770 /**
771 * Get list of buffers from the server
772 *
773 * Gets a list of buffer for the specified set of attachments. Unlike
774 * \c ::getBuffers, this function takes a list of attachments paired with
775 * opaque \c unsigned \c int value describing the format of the buffer.
776 * It is the responsibility of the caller to know what the service that
777 * allocates the buffers will expect to receive for the format.
778 *
779 * \param driDrawable Drawable whose buffers are being queried.
780 * \param width Output where the width of the buffers is stored.
781 * \param height Output where the height of the buffers is stored.
782 * \param attachments List of pairs of attachment ID and opaque format
783 * requested for the drawable.
784 * \param count Number of attachment / format pairs stored in
785 * \c attachments.
786 * \param loaderPrivate Loader's private data that was previously passed
787 * into __DRIdri2ExtensionRec::createNewDrawable.
788 */
789 __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
790 int *width, int *height,
791 unsigned int *attachments, int count,
792 int *out_count, void *loaderPrivate);
793 };
794
795 /**
796 * This extension provides alternative screen, drawable and context
797 * constructors for DRI2.
798 */
799 #define __DRI_DRI2 "DRI_DRI2"
800 #define __DRI_DRI2_VERSION 3
801
802 #define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
803 #define __DRI_API_GLES 1
804 #define __DRI_API_GLES2 2
805 #define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
806
807 #define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
808 #define __DRI_CTX_ATTRIB_MINOR_VERSION 1
809 #define __DRI_CTX_ATTRIB_FLAGS 2
810
811 #define __DRI_CTX_FLAG_DEBUG 0x00000001
812 #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
813
814 /**
815 * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
816 */
817 /*@{*/
818 /** Success! */
819 #define __DRI_CTX_ERROR_SUCCESS 0
820
821 /** Memory allocation failure */
822 #define __DRI_CTX_ERROR_NO_MEMORY 1
823
824 /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
825 #define __DRI_CTX_ERROR_BAD_API 2
826
827 /** Client requested an API version that the driver can't do. */
828 #define __DRI_CTX_ERROR_BAD_VERSION 3
829
830 /** Client requested a flag or combination of flags the driver can't do. */
831 #define __DRI_CTX_ERROR_BAD_FLAG 4
832
833 /** Client requested an attribute the driver doesn't understand. */
834 #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
835
836 /** Client requested a flag the driver doesn't understand. */
837 #define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
838 /*@}*/
839
840 struct __DRIdri2ExtensionRec {
841 __DRIextension base;
842
843 __DRIscreen *(*createNewScreen)(int screen, int fd,
844 const __DRIextension **extensions,
845 const __DRIconfig ***driver_configs,
846 void *loaderPrivate);
847
848 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
849 const __DRIconfig *config,
850 void *loaderPrivate);
851
852 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
853 const __DRIconfig *config,
854 __DRIcontext *shared,
855 void *loaderPrivate);
856
857 /* Since version 2 */
858 unsigned int (*getAPIMask)(__DRIscreen *screen);
859
860 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
861 int api,
862 const __DRIconfig *config,
863 __DRIcontext *shared,
864 void *data);
865
866 __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
867 unsigned int attachment,
868 unsigned int format,
869 int width,
870 int height);
871 void (*releaseBuffer)(__DRIscreen *screen,
872 __DRIbuffer *buffer);
873
874 /**
875 * Create a context for a particular API with a set of attributes
876 *
877 * \since version 3
878 *
879 * \sa __DRIswrastExtensionRec::createContextAttribs
880 */
881 __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
882 int api,
883 const __DRIconfig *config,
884 __DRIcontext *shared,
885 unsigned num_attribs,
886 const uint32_t *attribs,
887 unsigned *error,
888 void *loaderPrivate);
889 };
890
891
892 /**
893 * This extension provides functionality to enable various EGLImage
894 * extensions.
895 */
896 #define __DRI_IMAGE "DRI_IMAGE"
897 #define __DRI_IMAGE_VERSION 4
898
899 /**
900 * These formats correspond to the similarly named MESA_FORMAT_*
901 * tokens, except in the native endian of the CPU. For example, on
902 * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
903 * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
904 */
905 #define __DRI_IMAGE_FORMAT_RGB565 0x1001
906 #define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
907 #define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
908 #define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
909 #define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
910
911 #define __DRI_IMAGE_USE_SHARE 0x0001
912 #define __DRI_IMAGE_USE_SCANOUT 0x0002
913 #define __DRI_IMAGE_USE_CURSOR 0x0004
914 #define __DRI_IMAGE_USE_WRITE 0x0008
915
916 /**
917 * queryImage attributes
918 */
919
920 #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
921 #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
922 #define __DRI_IMAGE_ATTRIB_NAME 0x2002
923 #define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
924
925 typedef struct __DRIimageRec __DRIimage;
926 typedef struct __DRIimageExtensionRec __DRIimageExtension;
927 struct __DRIimageExtensionRec {
928 __DRIextension base;
929
930 __DRIimage *(*createImageFromName)(__DRIscreen *screen,
931 int width, int height, int format,
932 int name, int pitch,
933 void *loaderPrivate);
934
935 __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
936 int renderbuffer,
937 void *loaderPrivate);
938
939 void (*destroyImage)(__DRIimage *image);
940
941 __DRIimage *(*createImage)(__DRIscreen *screen,
942 int width, int height, int format,
943 unsigned int use,
944 void *loaderPrivate);
945
946 GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
947
948 /**
949 * The new __DRIimage will share the content with the old one, see dup(2).
950 */
951 __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
952
953 /**
954 * Validate that a __DRIimage can be used a certain way.
955 *
956 * \since 2
957 */
958 GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
959
960 /**
961 * Write data into image.
962 *
963 * \since 4
964 */
965 int (*write)(__DRIimage *image, const void *buf, size_t count);
966 };
967
968
969 /**
970 * This extension must be implemented by the loader and passed to the
971 * driver at screen creation time. The EGLImage entry points in the
972 * various client APIs take opaque EGLImage handles and use this
973 * extension to map them to a __DRIimage. At version 1, this
974 * extensions allows mapping EGLImage pointers to __DRIimage pointers,
975 * but future versions could support other EGLImage-like, opaque types
976 * with new lookup functions.
977 */
978 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
979 #define __DRI_IMAGE_LOOKUP_VERSION 1
980
981 typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
982 struct __DRIimageLookupExtensionRec {
983 __DRIextension base;
984
985 __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
986 void *loaderPrivate);
987 };
988
989 /**
990 * This extension allows for common DRI2 options
991 */
992 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
993 #define __DRI2_CONFIG_QUERY_VERSION 1
994
995 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
996 struct __DRI2configQueryExtensionRec {
997 __DRIextension base;
998
999 int (*configQueryb)(__DRIscreen *screen, const char *var, GLboolean *val);
1000 int (*configQueryi)(__DRIscreen *screen, const char *var, GLint *val);
1001 int (*configQueryf)(__DRIscreen *screen, const char *var, GLfloat *val);
1002 };
1003 #endif