dri: define a version 2 of the DRI_ConfigOptions extension
[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 #ifdef HAVE_LIBDRM
44 #include <drm.h>
45 #else
46 typedef unsigned int drm_context_t;
47 typedef unsigned int drm_drawable_t;
48 typedef struct drm_clip_rect drm_clip_rect_t;
49 #endif
50
51 /**
52 * \name DRI interface structures
53 *
54 * The following structures define the interface between the GLX client
55 * side library and the DRI (direct rendering infrastructure).
56 */
57 /*@{*/
58 typedef struct __DRIdisplayRec __DRIdisplay;
59 typedef struct __DRIscreenRec __DRIscreen;
60 typedef struct __DRIcontextRec __DRIcontext;
61 typedef struct __DRIdrawableRec __DRIdrawable;
62 typedef struct __DRIconfigRec __DRIconfig;
63 typedef struct __DRIframebufferRec __DRIframebuffer;
64 typedef struct __DRIversionRec __DRIversion;
65
66 typedef struct __DRIcoreExtensionRec __DRIcoreExtension;
67 typedef struct __DRIextensionRec __DRIextension;
68 typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
69 typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
70 typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
71 typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
72 typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
73 typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;
74 typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;
75 typedef struct __DRIswrastExtensionRec __DRIswrastExtension;
76 typedef struct __DRIbufferRec __DRIbuffer;
77 typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;
78 typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;
79 typedef struct __DRI2flushExtensionRec __DRI2flushExtension;
80 typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension;
81 typedef struct __DRI2fenceExtensionRec __DRI2fenceExtension;
82 typedef struct __DRI2interopExtensionRec __DRI2interopExtension;
83
84
85 typedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension;
86 typedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension;
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 3
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 * \since 2
251 */
252 void (*setTexBuffer2)(__DRIcontext *pDRICtx,
253 GLint target,
254 GLint format,
255 __DRIdrawable *pDraw);
256 /**
257 * Method to release texture buffer in case some special platform
258 * need this.
259 *
260 * For GLX_EXT_texture_from_pixmap with AIGLX.
261 *
262 * \since 3
263 */
264 void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
265 GLint target,
266 __DRIdrawable *pDraw);
267 };
268
269 /**
270 * Used by drivers that implement DRI2
271 */
272 #define __DRI2_FLUSH "DRI2_Flush"
273 #define __DRI2_FLUSH_VERSION 4
274
275 #define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
276 #define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */
277 #define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2)
278
279 enum __DRI2throttleReason {
280 __DRI2_THROTTLE_SWAPBUFFER,
281 __DRI2_THROTTLE_COPYSUBBUFFER,
282 __DRI2_THROTTLE_FLUSHFRONT
283 };
284
285 struct __DRI2flushExtensionRec {
286 __DRIextension base;
287 void (*flush)(__DRIdrawable *drawable);
288
289 /**
290 * Ask the driver to call getBuffers/getBuffersWithFormat before
291 * it starts rendering again.
292 *
293 * \param drawable the drawable to invalidate
294 *
295 * \since 3
296 */
297 void (*invalidate)(__DRIdrawable *drawable);
298
299 /**
300 * This function reduces the number of flushes in the driver by combining
301 * several operations into one call.
302 *
303 * It can:
304 * - throttle
305 * - flush a drawable
306 * - flush a context
307 *
308 * \param context the context
309 * \param drawable the drawable to flush
310 * \param flags a combination of _DRI2_FLUSH_xxx flags
311 * \param throttle_reason the reason for throttling, 0 = no throttling
312 *
313 * \since 4
314 */
315 void (*flush_with_flags)(__DRIcontext *ctx,
316 __DRIdrawable *drawable,
317 unsigned flags,
318 enum __DRI2throttleReason throttle_reason);
319 };
320
321
322 /**
323 * Extension that the driver uses to request
324 * throttle callbacks.
325 */
326
327 #define __DRI2_THROTTLE "DRI2_Throttle"
328 #define __DRI2_THROTTLE_VERSION 1
329
330 struct __DRI2throttleExtensionRec {
331 __DRIextension base;
332 void (*throttle)(__DRIcontext *ctx,
333 __DRIdrawable *drawable,
334 enum __DRI2throttleReason reason);
335 };
336
337
338 /**
339 * Extension for fences / synchronization objects.
340 */
341
342 #define __DRI2_FENCE "DRI2_Fence"
343 #define __DRI2_FENCE_VERSION 2
344
345 #define __DRI2_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffull
346
347 #define __DRI2_FENCE_FLAG_FLUSH_COMMANDS (1 << 0)
348
349 /**
350 * \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities
351 */
352 /*@{*/
353 #define __DRI_FENCE_CAP_NATIVE_FD 1
354 /*@}*/
355
356 struct __DRI2fenceExtensionRec {
357 __DRIextension base;
358
359 /**
360 * Create and insert a fence into the command stream of the context.
361 */
362 void *(*create_fence)(__DRIcontext *ctx);
363
364 /**
365 * Get a fence associated with the OpenCL event object.
366 * This can be NULL, meaning that OpenCL interoperability is not supported.
367 */
368 void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event);
369
370 /**
371 * Destroy a fence.
372 */
373 void (*destroy_fence)(__DRIscreen *screen, void *fence);
374
375 /**
376 * This function waits and doesn't return until the fence is signalled
377 * or the timeout expires. It returns true if the fence has been signaled.
378 *
379 * \param ctx the context where commands are flushed
380 * \param fence the fence
381 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags
382 * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE
383 */
384 GLboolean (*client_wait_sync)(__DRIcontext *ctx, void *fence,
385 unsigned flags, uint64_t timeout);
386
387 /**
388 * This function enqueues a wait command into the command stream of
389 * the context and then returns. When the execution reaches the wait
390 * command, no further execution will be done in the context until
391 * the fence is signaled. This is a no-op if the device doesn't support
392 * parallel execution of contexts.
393 *
394 * \param ctx the context where the waiting is done
395 * \param fence the fence
396 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags that make
397 * sense with this function (right now there are none)
398 */
399 void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags);
400
401 /**
402 * Query for general capabilities of the driver that concern fences.
403 * Returns a bitmask of __DRI_FENCE_CAP_x
404 *
405 * \since 2
406 */
407 unsigned (*get_capabilities)(__DRIscreen *screen);
408
409 /**
410 * Create an fd (file descriptor) associated fence. If the fence fd
411 * is -1, this behaves similarly to create_fence() except that when
412 * rendering is flushed the driver creates a fence fd. Otherwise,
413 * the driver wraps an existing fence fd.
414 *
415 * This is used to implement the EGL_ANDROID_native_fence_sync extension.
416 *
417 * \since 2
418 *
419 * \param ctx the context associated with the fence
420 * \param fd the fence fd or -1
421 */
422 void *(*create_fence_fd)(__DRIcontext *ctx, int fd);
423
424 /**
425 * For fences created with create_fence_fd(), after rendering is flushed,
426 * this retrieves the native fence fd. Caller takes ownership of the
427 * fd and will close() it when it is no longer needed.
428 *
429 * \since 2
430 *
431 * \param screen the screen associated with the fence
432 * \param fence the fence
433 */
434 int (*get_fence_fd)(__DRIscreen *screen, void *fence);
435 };
436
437
438 /**
439 * Extension for API interop.
440 * See GL/mesa_glinterop.h.
441 */
442
443 #define __DRI2_INTEROP "DRI2_Interop"
444 #define __DRI2_INTEROP_VERSION 1
445
446 struct mesa_glinterop_device_info;
447 struct mesa_glinterop_export_in;
448 struct mesa_glinterop_export_out;
449
450 struct __DRI2interopExtensionRec {
451 __DRIextension base;
452
453 /** Same as MesaGLInterop*QueryDeviceInfo. */
454 int (*query_device_info)(__DRIcontext *ctx,
455 struct mesa_glinterop_device_info *out);
456
457 /** Same as MesaGLInterop*ExportObject. */
458 int (*export_object)(__DRIcontext *ctx,
459 struct mesa_glinterop_export_in *in,
460 struct mesa_glinterop_export_out *out);
461 };
462
463 /*@}*/
464
465 /**
466 * The following extensions describe loader features that the DRI
467 * driver can make use of. Some of these are mandatory, such as the
468 * getDrawableInfo extension for DRI and the DRI Loader extensions for
469 * DRI2, while others are optional, and if present allow the driver to
470 * expose certain features. The loader pass in a NULL terminated
471 * array of these extensions to the driver in the createNewScreen
472 * constructor.
473 */
474
475 typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
476 typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
477 typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
478 typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
479 typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
480
481
482 /**
483 * Callback to getDrawableInfo protocol
484 */
485 #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
486 #define __DRI_GET_DRAWABLE_INFO_VERSION 1
487 struct __DRIgetDrawableInfoExtensionRec {
488 __DRIextension base;
489
490 /**
491 * This function is used to get information about the position, size, and
492 * clip rects of a drawable.
493 */
494 GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
495 unsigned int * index, unsigned int * stamp,
496 int * x, int * y, int * width, int * height,
497 int * numClipRects, drm_clip_rect_t ** pClipRects,
498 int * backX, int * backY,
499 int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
500 void *loaderPrivate);
501 };
502
503 /**
504 * Callback to get system time for media stream counter extensions.
505 */
506 #define __DRI_SYSTEM_TIME "DRI_SystemTime"
507 #define __DRI_SYSTEM_TIME_VERSION 1
508 struct __DRIsystemTimeExtensionRec {
509 __DRIextension base;
510
511 /**
512 * Get the 64-bit unadjusted system time (UST).
513 */
514 int (*getUST)(int64_t * ust);
515
516 /**
517 * Get the media stream counter (MSC) rate.
518 *
519 * Matching the definition in GLX_OML_sync_control, this function returns
520 * the rate of the "media stream counter". In practical terms, this is
521 * the frame refresh rate of the display.
522 */
523 GLboolean (*getMSCRate)(__DRIdrawable *draw,
524 int32_t * numerator, int32_t * denominator,
525 void *loaderPrivate);
526 };
527
528 /**
529 * Damage reporting
530 */
531 #define __DRI_DAMAGE "DRI_Damage"
532 #define __DRI_DAMAGE_VERSION 1
533 struct __DRIdamageExtensionRec {
534 __DRIextension base;
535
536 /**
537 * Reports areas of the given drawable which have been modified by the
538 * driver.
539 *
540 * \param drawable which the drawing was done to.
541 * \param rects rectangles affected, with the drawable origin as the
542 * origin.
543 * \param x X offset of the drawable within the screen (used in the
544 * front_buffer case)
545 * \param y Y offset of the drawable within the screen.
546 * \param front_buffer boolean flag for whether the drawing to the
547 * drawable was actually done directly to the front buffer (instead
548 * of backing storage, for example)
549 * \param loaderPrivate the data passed in at createNewDrawable time
550 */
551 void (*reportDamage)(__DRIdrawable *draw,
552 int x, int y,
553 drm_clip_rect_t *rects, int num_rects,
554 GLboolean front_buffer,
555 void *loaderPrivate);
556 };
557
558 #define __DRI_SWRAST_IMAGE_OP_DRAW 1
559 #define __DRI_SWRAST_IMAGE_OP_CLEAR 2
560 #define __DRI_SWRAST_IMAGE_OP_SWAP 3
561
562 /**
563 * SWRast Loader extension.
564 */
565 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
566 #define __DRI_SWRAST_LOADER_VERSION 3
567 struct __DRIswrastLoaderExtensionRec {
568 __DRIextension base;
569
570 /*
571 * Drawable position and size
572 */
573 void (*getDrawableInfo)(__DRIdrawable *drawable,
574 int *x, int *y, int *width, int *height,
575 void *loaderPrivate);
576
577 /**
578 * Put image to drawable
579 */
580 void (*putImage)(__DRIdrawable *drawable, int op,
581 int x, int y, int width, int height,
582 char *data, void *loaderPrivate);
583
584 /**
585 * Get image from readable
586 */
587 void (*getImage)(__DRIdrawable *readable,
588 int x, int y, int width, int height,
589 char *data, void *loaderPrivate);
590
591 /**
592 * Put image to drawable
593 *
594 * \since 2
595 */
596 void (*putImage2)(__DRIdrawable *drawable, int op,
597 int x, int y, int width, int height, int stride,
598 char *data, void *loaderPrivate);
599
600 /**
601 * Put image to drawable
602 *
603 * \since 3
604 */
605 void (*getImage2)(__DRIdrawable *readable,
606 int x, int y, int width, int height, int stride,
607 char *data, void *loaderPrivate);
608 };
609
610 /**
611 * Invalidate loader extension. The presence of this extension
612 * indicates to the DRI driver that the loader will call invalidate in
613 * the __DRI2_FLUSH extension, whenever the needs to query for new
614 * buffers. This means that the DRI driver can drop the polling in
615 * glViewport().
616 *
617 * The extension doesn't provide any functionality, it's only use to
618 * indicate to the driver that it can use the new semantics. A DRI
619 * driver can use this to switch between the different semantics or
620 * just refuse to initialize if this extension isn't present.
621 */
622 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
623 #define __DRI_USE_INVALIDATE_VERSION 1
624
625 typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
626 struct __DRIuseInvalidateExtensionRec {
627 __DRIextension base;
628 };
629
630 /**
631 * The remaining extensions describe driver extensions, immediately
632 * available interfaces provided by the driver. To start using the
633 * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
634 * the extension you need in the array.
635 */
636 #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
637
638 /**
639 * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
640 * suffixed by "_drivername", allowing multiple drivers to be built into one
641 * library, and also giving the driver the chance to return a variable driver
642 * extensions struct depending on the driver name being loaded or any other
643 * system state.
644 *
645 * The function prototype is:
646 *
647 * const __DRIextension **__driDriverGetExtensions_drivername(void);
648 */
649 #define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
650
651 /**
652 * Tokens for __DRIconfig attribs. A number of attributes defined by
653 * GLX or EGL standards are not in the table, as they must be provided
654 * by the loader. For example, FBConfig ID or visual ID, drawable type.
655 */
656
657 #define __DRI_ATTRIB_BUFFER_SIZE 1
658 #define __DRI_ATTRIB_LEVEL 2
659 #define __DRI_ATTRIB_RED_SIZE 3
660 #define __DRI_ATTRIB_GREEN_SIZE 4
661 #define __DRI_ATTRIB_BLUE_SIZE 5
662 #define __DRI_ATTRIB_LUMINANCE_SIZE 6
663 #define __DRI_ATTRIB_ALPHA_SIZE 7
664 #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
665 #define __DRI_ATTRIB_DEPTH_SIZE 9
666 #define __DRI_ATTRIB_STENCIL_SIZE 10
667 #define __DRI_ATTRIB_ACCUM_RED_SIZE 11
668 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
669 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
670 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
671 #define __DRI_ATTRIB_SAMPLE_BUFFERS 15
672 #define __DRI_ATTRIB_SAMPLES 16
673 #define __DRI_ATTRIB_RENDER_TYPE 17
674 #define __DRI_ATTRIB_CONFIG_CAVEAT 18
675 #define __DRI_ATTRIB_CONFORMANT 19
676 #define __DRI_ATTRIB_DOUBLE_BUFFER 20
677 #define __DRI_ATTRIB_STEREO 21
678 #define __DRI_ATTRIB_AUX_BUFFERS 22
679 #define __DRI_ATTRIB_TRANSPARENT_TYPE 23
680 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
681 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
682 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
683 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
684 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
685 #define __DRI_ATTRIB_FLOAT_MODE 29
686 #define __DRI_ATTRIB_RED_MASK 30
687 #define __DRI_ATTRIB_GREEN_MASK 31
688 #define __DRI_ATTRIB_BLUE_MASK 32
689 #define __DRI_ATTRIB_ALPHA_MASK 33
690 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
691 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
692 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
693 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
694 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
695 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
696 #define __DRI_ATTRIB_SWAP_METHOD 40
697 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
698 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
699 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
700 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
701 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
702 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
703 #define __DRI_ATTRIB_YINVERTED 47
704 #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
705 #define __DRI_ATTRIB_MAX (__DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE + 1)
706
707 /* __DRI_ATTRIB_RENDER_TYPE */
708 #define __DRI_ATTRIB_RGBA_BIT 0x01
709 #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
710 #define __DRI_ATTRIB_LUMINANCE_BIT 0x04
711 #define __DRI_ATTRIB_FLOAT_BIT 0x08
712 #define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10
713
714 /* __DRI_ATTRIB_CONFIG_CAVEAT */
715 #define __DRI_ATTRIB_SLOW_BIT 0x01
716 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
717
718 /* __DRI_ATTRIB_TRANSPARENT_TYPE */
719 #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
720 #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
721
722 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
723 #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
724 #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
725 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
726
727 /**
728 * This extension defines the core DRI functionality.
729 */
730 #define __DRI_CORE "DRI_Core"
731 #define __DRI_CORE_VERSION 1
732
733 struct __DRIcoreExtensionRec {
734 __DRIextension base;
735
736 __DRIscreen *(*createNewScreen)(int screen, int fd,
737 unsigned int sarea_handle,
738 const __DRIextension **extensions,
739 const __DRIconfig ***driverConfigs,
740 void *loaderPrivate);
741
742 void (*destroyScreen)(__DRIscreen *screen);
743
744 const __DRIextension **(*getExtensions)(__DRIscreen *screen);
745
746 int (*getConfigAttrib)(const __DRIconfig *config,
747 unsigned int attrib,
748 unsigned int *value);
749
750 int (*indexConfigAttrib)(const __DRIconfig *config, int index,
751 unsigned int *attrib, unsigned int *value);
752
753 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
754 const __DRIconfig *config,
755 unsigned int drawable_id,
756 unsigned int head,
757 void *loaderPrivate);
758
759 void (*destroyDrawable)(__DRIdrawable *drawable);
760
761 void (*swapBuffers)(__DRIdrawable *drawable);
762
763 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
764 const __DRIconfig *config,
765 __DRIcontext *shared,
766 void *loaderPrivate);
767
768 int (*copyContext)(__DRIcontext *dest,
769 __DRIcontext *src,
770 unsigned long mask);
771
772 void (*destroyContext)(__DRIcontext *context);
773
774 int (*bindContext)(__DRIcontext *ctx,
775 __DRIdrawable *pdraw,
776 __DRIdrawable *pread);
777
778 int (*unbindContext)(__DRIcontext *ctx);
779 };
780
781 /**
782 * Stored version of some component (i.e., server-side DRI module, kernel-side
783 * DRM, etc.).
784 *
785 * \todo
786 * There are several data structures that explicitly store a major version,
787 * minor version, and patch level. These structures should be modified to
788 * have a \c __DRIversionRec instead.
789 */
790 struct __DRIversionRec {
791 int major; /**< Major version number. */
792 int minor; /**< Minor version number. */
793 int patch; /**< Patch-level. */
794 };
795
796 /**
797 * Framebuffer information record. Used by libGL to communicate information
798 * about the framebuffer to the driver's \c __driCreateNewScreen function.
799 *
800 * In XFree86, most of this information is derrived from data returned by
801 * calling \c XF86DRIGetDeviceInfo.
802 *
803 * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
804 * __driUtilCreateNewScreen CallCreateNewScreen
805 *
806 * \bug This structure could be better named.
807 */
808 struct __DRIframebufferRec {
809 unsigned char *base; /**< Framebuffer base address in the CPU's
810 * address space. This value is calculated by
811 * calling \c drmMap on the framebuffer handle
812 * returned by \c XF86DRIGetDeviceInfo (or a
813 * similar function).
814 */
815 int size; /**< Framebuffer size, in bytes. */
816 int stride; /**< Number of bytes from one line to the next. */
817 int width; /**< Pixel width of the framebuffer. */
818 int height; /**< Pixel height of the framebuffer. */
819 int dev_priv_size; /**< Size of the driver's dev-priv structure. */
820 void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
821 };
822
823
824 /**
825 * This extension provides alternative screen, drawable and context
826 * constructors for legacy DRI functionality. This is used in
827 * conjunction with the core extension.
828 */
829 #define __DRI_LEGACY "DRI_Legacy"
830 #define __DRI_LEGACY_VERSION 1
831
832 struct __DRIlegacyExtensionRec {
833 __DRIextension base;
834
835 __DRIscreen *(*createNewScreen)(int screen,
836 const __DRIversion *ddx_version,
837 const __DRIversion *dri_version,
838 const __DRIversion *drm_version,
839 const __DRIframebuffer *frame_buffer,
840 void *pSAREA, int fd,
841 const __DRIextension **extensions,
842 const __DRIconfig ***driver_configs,
843 void *loaderPrivate);
844
845 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
846 const __DRIconfig *config,
847 drm_drawable_t hwDrawable,
848 int renderType, const int *attrs,
849 void *loaderPrivate);
850
851 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
852 const __DRIconfig *config,
853 int render_type,
854 __DRIcontext *shared,
855 drm_context_t hwContext,
856 void *loaderPrivate);
857 };
858
859 /**
860 * This extension provides alternative screen, drawable and context
861 * constructors for swrast DRI functionality. This is used in
862 * conjunction with the core extension.
863 */
864 #define __DRI_SWRAST "DRI_SWRast"
865 #define __DRI_SWRAST_VERSION 4
866
867 struct __DRIswrastExtensionRec {
868 __DRIextension base;
869
870 __DRIscreen *(*createNewScreen)(int screen,
871 const __DRIextension **extensions,
872 const __DRIconfig ***driver_configs,
873 void *loaderPrivate);
874
875 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
876 const __DRIconfig *config,
877 void *loaderPrivate);
878
879 /* Since version 2 */
880 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
881 int api,
882 const __DRIconfig *config,
883 __DRIcontext *shared,
884 void *data);
885
886 /**
887 * Create a context for a particular API with a set of attributes
888 *
889 * \since version 3
890 *
891 * \sa __DRIdri2ExtensionRec::createContextAttribs
892 */
893 __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
894 int api,
895 const __DRIconfig *config,
896 __DRIcontext *shared,
897 unsigned num_attribs,
898 const uint32_t *attribs,
899 unsigned *error,
900 void *loaderPrivate);
901
902 /**
903 * createNewScreen() with the driver extensions passed in.
904 *
905 * \since version 4
906 */
907 __DRIscreen *(*createNewScreen2)(int screen,
908 const __DRIextension **loader_extensions,
909 const __DRIextension **driver_extensions,
910 const __DRIconfig ***driver_configs,
911 void *loaderPrivate);
912
913 };
914
915 /** Common DRI function definitions, shared among DRI2 and Image extensions
916 */
917
918 typedef __DRIscreen *
919 (*__DRIcreateNewScreen2Func)(int screen, int fd,
920 const __DRIextension **extensions,
921 const __DRIextension **driver_extensions,
922 const __DRIconfig ***driver_configs,
923 void *loaderPrivate);
924
925 typedef __DRIdrawable *
926 (*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
927 const __DRIconfig *config,
928 void *loaderPrivate);
929
930 typedef __DRIcontext *
931 (*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
932 int api,
933 const __DRIconfig *config,
934 __DRIcontext *shared,
935 unsigned num_attribs,
936 const uint32_t *attribs,
937 unsigned *error,
938 void *loaderPrivate);
939
940 typedef unsigned int
941 (*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
942
943 /**
944 * DRI2 Loader extension.
945 */
946 #define __DRI_BUFFER_FRONT_LEFT 0
947 #define __DRI_BUFFER_BACK_LEFT 1
948 #define __DRI_BUFFER_FRONT_RIGHT 2
949 #define __DRI_BUFFER_BACK_RIGHT 3
950 #define __DRI_BUFFER_DEPTH 4
951 #define __DRI_BUFFER_STENCIL 5
952 #define __DRI_BUFFER_ACCUM 6
953 #define __DRI_BUFFER_FAKE_FRONT_LEFT 7
954 #define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
955 #define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
956 #define __DRI_BUFFER_HIZ 10
957
958 /* Inofficial and for internal use. Increase when adding a new buffer token. */
959 #define __DRI_BUFFER_COUNT 11
960
961 struct __DRIbufferRec {
962 unsigned int attachment;
963 unsigned int name;
964 unsigned int pitch;
965 unsigned int cpp;
966 unsigned int flags;
967 };
968
969 #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
970 #define __DRI_DRI2_LOADER_VERSION 4
971
972 enum dri_loader_cap {
973 /* Whether the loader handles RGBA channel ordering correctly. If not,
974 * only BGRA ordering can be exposed.
975 */
976 DRI_LOADER_CAP_RGBA_ORDERING,
977 };
978
979 struct __DRIdri2LoaderExtensionRec {
980 __DRIextension base;
981
982 __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
983 int *width, int *height,
984 unsigned int *attachments, int count,
985 int *out_count, void *loaderPrivate);
986
987 /**
988 * Flush pending front-buffer rendering
989 *
990 * Any rendering that has been performed to the
991 * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
992 * \c __DRI_BUFFER_FRONT_LEFT.
993 *
994 * \param driDrawable Drawable whose front-buffer is to be flushed
995 * \param loaderPrivate Loader's private data that was previously passed
996 * into __DRIdri2ExtensionRec::createNewDrawable
997 *
998 * \since 2
999 */
1000 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
1001
1002
1003 /**
1004 * Get list of buffers from the server
1005 *
1006 * Gets a list of buffer for the specified set of attachments. Unlike
1007 * \c ::getBuffers, this function takes a list of attachments paired with
1008 * opaque \c unsigned \c int value describing the format of the buffer.
1009 * It is the responsibility of the caller to know what the service that
1010 * allocates the buffers will expect to receive for the format.
1011 *
1012 * \param driDrawable Drawable whose buffers are being queried.
1013 * \param width Output where the width of the buffers is stored.
1014 * \param height Output where the height of the buffers is stored.
1015 * \param attachments List of pairs of attachment ID and opaque format
1016 * requested for the drawable.
1017 * \param count Number of attachment / format pairs stored in
1018 * \c attachments.
1019 * \param loaderPrivate Loader's private data that was previously passed
1020 * into __DRIdri2ExtensionRec::createNewDrawable.
1021 *
1022 * \since 3
1023 */
1024 __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
1025 int *width, int *height,
1026 unsigned int *attachments, int count,
1027 int *out_count, void *loaderPrivate);
1028
1029 /**
1030 * Return a loader capability value. If the loader doesn't know the enum,
1031 * it will return 0.
1032 *
1033 * \param loaderPrivate The last parameter of createNewScreen or
1034 * createNewScreen2.
1035 * \param cap See the enum.
1036 *
1037 * \since 4
1038 */
1039 unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
1040 };
1041
1042 /**
1043 * This extension provides alternative screen, drawable and context
1044 * constructors for DRI2.
1045 */
1046 #define __DRI_DRI2 "DRI_DRI2"
1047 #define __DRI_DRI2_VERSION 4
1048
1049 #define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
1050 #define __DRI_API_GLES 1 /**< OpenGL ES 1.x */
1051 #define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */
1052 #define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
1053 #define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */
1054
1055 #define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
1056 #define __DRI_CTX_ATTRIB_MINOR_VERSION 1
1057 #define __DRI_CTX_ATTRIB_FLAGS 2
1058
1059 /**
1060 * \requires __DRI2_ROBUSTNESS.
1061 */
1062 #define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
1063
1064 #define __DRI_CTX_FLAG_DEBUG 0x00000001
1065 #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
1066
1067 /**
1068 * \requires __DRI2_ROBUSTNESS.
1069 */
1070 #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004
1071
1072 /**
1073 * \requires __DRI2_NO_ERROR.
1074 *
1075 */
1076 #define __DRI_CTX_FLAG_NO_ERROR 0x00000008
1077
1078 /**
1079 * \name Context reset strategies.
1080 */
1081 /*@{*/
1082 #define __DRI_CTX_RESET_NO_NOTIFICATION 0
1083 #define __DRI_CTX_RESET_LOSE_CONTEXT 1
1084 /*@}*/
1085
1086 /**
1087 * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
1088 */
1089 /*@{*/
1090 /** Success! */
1091 #define __DRI_CTX_ERROR_SUCCESS 0
1092
1093 /** Memory allocation failure */
1094 #define __DRI_CTX_ERROR_NO_MEMORY 1
1095
1096 /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
1097 #define __DRI_CTX_ERROR_BAD_API 2
1098
1099 /** Client requested an API version that the driver can't do. */
1100 #define __DRI_CTX_ERROR_BAD_VERSION 3
1101
1102 /** Client requested a flag or combination of flags the driver can't do. */
1103 #define __DRI_CTX_ERROR_BAD_FLAG 4
1104
1105 /** Client requested an attribute the driver doesn't understand. */
1106 #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
1107
1108 /** Client requested a flag the driver doesn't understand. */
1109 #define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
1110 /*@}*/
1111
1112 struct __DRIdri2ExtensionRec {
1113 __DRIextension base;
1114
1115 __DRIscreen *(*createNewScreen)(int screen, int fd,
1116 const __DRIextension **extensions,
1117 const __DRIconfig ***driver_configs,
1118 void *loaderPrivate);
1119
1120 __DRIcreateNewDrawableFunc createNewDrawable;
1121 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
1122 const __DRIconfig *config,
1123 __DRIcontext *shared,
1124 void *loaderPrivate);
1125
1126 /* Since version 2 */
1127 __DRIgetAPIMaskFunc getAPIMask;
1128
1129 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
1130 int api,
1131 const __DRIconfig *config,
1132 __DRIcontext *shared,
1133 void *data);
1134
1135 __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
1136 unsigned int attachment,
1137 unsigned int format,
1138 int width,
1139 int height);
1140 void (*releaseBuffer)(__DRIscreen *screen,
1141 __DRIbuffer *buffer);
1142
1143 /**
1144 * Create a context for a particular API with a set of attributes
1145 *
1146 * \since version 3
1147 *
1148 * \sa __DRIswrastExtensionRec::createContextAttribs
1149 */
1150 __DRIcreateContextAttribsFunc createContextAttribs;
1151
1152 /**
1153 * createNewScreen with the driver's extension list passed in.
1154 *
1155 * \since version 4
1156 */
1157 __DRIcreateNewScreen2Func createNewScreen2;
1158 };
1159
1160
1161 /**
1162 * This extension provides functionality to enable various EGLImage
1163 * extensions.
1164 */
1165 #define __DRI_IMAGE "DRI_IMAGE"
1166 #define __DRI_IMAGE_VERSION 15
1167
1168 /**
1169 * These formats correspond to the similarly named MESA_FORMAT_*
1170 * tokens, except in the native endian of the CPU. For example, on
1171 * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
1172 * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
1173 *
1174 * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
1175 * by the driver (YUV planar formats) but serve as a base image for
1176 * creating sub-images for the different planes within the image.
1177 *
1178 * R8, GR88 and NONE should not be used with createImageFormName or
1179 * createImage, and are returned by query from sub images created with
1180 * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
1181 */
1182 #define __DRI_IMAGE_FORMAT_RGB565 0x1001
1183 #define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
1184 #define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
1185 #define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
1186 #define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
1187 #define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
1188 #define __DRI_IMAGE_FORMAT_GR88 0x1007
1189 #define __DRI_IMAGE_FORMAT_NONE 0x1008
1190 #define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
1191 #define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
1192 #define __DRI_IMAGE_FORMAT_SARGB8 0x100b
1193 #define __DRI_IMAGE_FORMAT_ARGB1555 0x100c
1194 #define __DRI_IMAGE_FORMAT_R16 0x100d
1195 #define __DRI_IMAGE_FORMAT_GR1616 0x100e
1196
1197 #define __DRI_IMAGE_USE_SHARE 0x0001
1198 #define __DRI_IMAGE_USE_SCANOUT 0x0002
1199 #define __DRI_IMAGE_USE_CURSOR 0x0004 /* Depricated */
1200 #define __DRI_IMAGE_USE_LINEAR 0x0008
1201 /* The buffer will only be read by an external process after SwapBuffers,
1202 * in contrary to gbm buffers, front buffers and fake front buffers, which
1203 * could be read after a flush."
1204 */
1205 #define __DRI_IMAGE_USE_BACKBUFFER 0x0010
1206
1207
1208 #define __DRI_IMAGE_TRANSFER_READ 0x1
1209 #define __DRI_IMAGE_TRANSFER_WRITE 0x2
1210 #define __DRI_IMAGE_TRANSFER_READ_WRITE \
1211 (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)
1212
1213 /**
1214 * Four CC formats that matches with WL_DRM_FORMAT_* from wayland_drm.h,
1215 * GBM_FORMAT_* from gbm.h, and DRM_FORMAT_* from drm_fourcc.h. Used with
1216 * createImageFromNames.
1217 *
1218 * \since 5
1219 */
1220
1221 #define __DRI_IMAGE_FOURCC_R8 0x20203852
1222 #define __DRI_IMAGE_FOURCC_GR88 0x38385247
1223 #define __DRI_IMAGE_FOURCC_ARGB1555 0x35315241
1224 #define __DRI_IMAGE_FOURCC_R16 0x20363152
1225 #define __DRI_IMAGE_FOURCC_GR1616 0x32335247
1226 #define __DRI_IMAGE_FOURCC_RGB565 0x36314752
1227 #define __DRI_IMAGE_FOURCC_ARGB8888 0x34325241
1228 #define __DRI_IMAGE_FOURCC_XRGB8888 0x34325258
1229 #define __DRI_IMAGE_FOURCC_ABGR8888 0x34324241
1230 #define __DRI_IMAGE_FOURCC_XBGR8888 0x34324258
1231 #define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258
1232 #define __DRI_IMAGE_FOURCC_YUV410 0x39565559
1233 #define __DRI_IMAGE_FOURCC_YUV411 0x31315559
1234 #define __DRI_IMAGE_FOURCC_YUV420 0x32315559
1235 #define __DRI_IMAGE_FOURCC_YUV422 0x36315559
1236 #define __DRI_IMAGE_FOURCC_YUV444 0x34325559
1237 #define __DRI_IMAGE_FOURCC_NV12 0x3231564e
1238 #define __DRI_IMAGE_FOURCC_NV16 0x3631564e
1239 #define __DRI_IMAGE_FOURCC_YUYV 0x56595559
1240 #define __DRI_IMAGE_FOURCC_UYVY 0x59565955
1241
1242 #define __DRI_IMAGE_FOURCC_YVU410 0x39555659
1243 #define __DRI_IMAGE_FOURCC_YVU411 0x31315659
1244 #define __DRI_IMAGE_FOURCC_YVU420 0x32315659
1245 #define __DRI_IMAGE_FOURCC_YVU422 0x36315659
1246 #define __DRI_IMAGE_FOURCC_YVU444 0x34325659
1247
1248 /**
1249 * Queryable on images created by createImageFromNames.
1250 *
1251 * RGB and RGBA are may be usable directly as images but its still
1252 * recommended to call fromPlanar with plane == 0.
1253 *
1254 * Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create
1255 * usable sub-images, sampling from images return raw YUV data and
1256 * color conversion needs to be done in the shader.
1257 *
1258 * \since 5
1259 */
1260
1261 #define __DRI_IMAGE_COMPONENTS_RGB 0x3001
1262 #define __DRI_IMAGE_COMPONENTS_RGBA 0x3002
1263 #define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
1264 #define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
1265 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
1266 #define __DRI_IMAGE_COMPONENTS_Y_UXVX 0x3008
1267 #define __DRI_IMAGE_COMPONENTS_R 0x3006
1268 #define __DRI_IMAGE_COMPONENTS_RG 0x3007
1269
1270
1271 /**
1272 * queryImage attributes
1273 */
1274
1275 #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
1276 #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
1277 #define __DRI_IMAGE_ATTRIB_NAME 0x2002
1278 #define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
1279 #define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */
1280 #define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005
1281 #define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */
1282 #define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions
1283 * 7+. Each query will return a
1284 * new fd. */
1285 #define __DRI_IMAGE_ATTRIB_FOURCC 0x2008 /* available in versions 11 */
1286 #define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */
1287
1288 #define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
1289 #define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */
1290 #define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */
1291
1292 enum __DRIYUVColorSpace {
1293 __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
1294 __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
1295 __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
1296 __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
1297 };
1298
1299 enum __DRISampleRange {
1300 __DRI_YUV_RANGE_UNDEFINED = 0,
1301 __DRI_YUV_FULL_RANGE = 0x3282,
1302 __DRI_YUV_NARROW_RANGE = 0x3283
1303 };
1304
1305 enum __DRIChromaSiting {
1306 __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
1307 __DRI_YUV_CHROMA_SITING_0 = 0x3284,
1308 __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
1309 };
1310
1311 /**
1312 * \name Reasons that __DRIimageExtensionRec::createImageFromTexture or
1313 * __DRIimageExtensionRec::createImageFromDmaBufs might fail
1314 */
1315 /*@{*/
1316 /** Success! */
1317 #define __DRI_IMAGE_ERROR_SUCCESS 0
1318
1319 /** Memory allocation failure */
1320 #define __DRI_IMAGE_ERROR_BAD_ALLOC 1
1321
1322 /** Client requested an invalid attribute */
1323 #define __DRI_IMAGE_ERROR_BAD_MATCH 2
1324
1325 /** Client requested an invalid texture object */
1326 #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
1327
1328 /** Client requested an invalid pitch and/or offset */
1329 #define __DRI_IMAGE_ERROR_BAD_ACCESS 4
1330 /*@}*/
1331
1332 /**
1333 * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
1334 */
1335 /*@{*/
1336 #define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
1337 /*@}*/
1338
1339 /**
1340 * blitImage flags
1341 */
1342
1343 #define __BLIT_FLAG_FLUSH 0x0001
1344 #define __BLIT_FLAG_FINISH 0x0002
1345
1346 typedef struct __DRIimageRec __DRIimage;
1347 typedef struct __DRIimageExtensionRec __DRIimageExtension;
1348 struct __DRIimageExtensionRec {
1349 __DRIextension base;
1350
1351 __DRIimage *(*createImageFromName)(__DRIscreen *screen,
1352 int width, int height, int format,
1353 int name, int pitch,
1354 void *loaderPrivate);
1355
1356 __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
1357 int renderbuffer,
1358 void *loaderPrivate);
1359
1360 void (*destroyImage)(__DRIimage *image);
1361
1362 __DRIimage *(*createImage)(__DRIscreen *screen,
1363 int width, int height, int format,
1364 unsigned int use,
1365 void *loaderPrivate);
1366
1367 GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
1368
1369 /**
1370 * The new __DRIimage will share the content with the old one, see dup(2).
1371 */
1372 __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
1373
1374 /**
1375 * Validate that a __DRIimage can be used a certain way.
1376 *
1377 * \since 2
1378 */
1379 GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
1380
1381 /**
1382 * Unlike createImageFromName __DRI_IMAGE_FORMAT is not but instead
1383 * __DRI_IMAGE_FOURCC and strides are in bytes not pixels. Stride is
1384 * also per block and not per pixel (for non-RGB, see gallium blocks).
1385 *
1386 * \since 5
1387 */
1388 __DRIimage *(*createImageFromNames)(__DRIscreen *screen,
1389 int width, int height, int fourcc,
1390 int *names, int num_names,
1391 int *strides, int *offsets,
1392 void *loaderPrivate);
1393
1394 /**
1395 * Create an image out of a sub-region of a parent image. This
1396 * entry point lets us create individual __DRIimages for different
1397 * planes in a planar buffer (typically yuv), for example. While a
1398 * sub-image shares the underlying buffer object with the parent
1399 * image and other sibling sub-images, the life times of parent and
1400 * sub-images are not dependent. Destroying the parent or a
1401 * sub-image doesn't affect other images. The underlying buffer
1402 * object is free when no __DRIimage remains that references it.
1403 *
1404 * Sub-images may overlap, but rendering to overlapping sub-images
1405 * is undefined.
1406 *
1407 * \since 5
1408 */
1409 __DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
1410 void *loaderPrivate);
1411
1412 /**
1413 * Create image from texture.
1414 *
1415 * \since 6
1416 */
1417 __DRIimage *(*createImageFromTexture)(__DRIcontext *context,
1418 int target,
1419 unsigned texture,
1420 int depth,
1421 int level,
1422 unsigned *error,
1423 void *loaderPrivate);
1424 /**
1425 * Like createImageFromNames, but takes a prime fd instead.
1426 *
1427 * \since 7
1428 */
1429 __DRIimage *(*createImageFromFds)(__DRIscreen *screen,
1430 int width, int height, int fourcc,
1431 int *fds, int num_fds,
1432 int *strides, int *offsets,
1433 void *loaderPrivate);
1434
1435 /**
1436 * Like createImageFromFds, but takes additional attributes.
1437 *
1438 * For EGL_EXT_image_dma_buf_import.
1439 *
1440 * \since 8
1441 */
1442 __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
1443 int width, int height, int fourcc,
1444 int *fds, int num_fds,
1445 int *strides, int *offsets,
1446 enum __DRIYUVColorSpace color_space,
1447 enum __DRISampleRange sample_range,
1448 enum __DRIChromaSiting horiz_siting,
1449 enum __DRIChromaSiting vert_siting,
1450 unsigned *error,
1451 void *loaderPrivate);
1452
1453 /**
1454 * Blit a part of a __DRIimage to another and flushes
1455 *
1456 * flush_flag:
1457 * 0: no flush
1458 * __BLIT_FLAG_FLUSH: flush after the blit operation
1459 * __BLIT_FLAG_FINISH: flush and wait the blit finished
1460 *
1461 * \since 9
1462 */
1463 void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
1464 int dstx0, int dsty0, int dstwidth, int dstheight,
1465 int srcx0, int srcy0, int srcwidth, int srcheight,
1466 int flush_flag);
1467
1468 /**
1469 * Query for general capabilities of the driver that concern
1470 * buffer sharing and image importing.
1471 *
1472 * \since 10
1473 */
1474 int (*getCapabilities)(__DRIscreen *screen);
1475
1476 /**
1477 * Returns a map of the specified region of a __DRIimage for the specified usage.
1478 *
1479 * flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the
1480 * mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ
1481 * is not included in the flags, the buffer content at map time is
1482 * undefined. Users wanting to modify the mapping must include
1483 * __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not
1484 * included, behaviour when writing the mapping is undefined.
1485 *
1486 * Returns the byte stride in *stride, and an opaque pointer to data
1487 * tracking the mapping in **data, which must be passed to unmapImage().
1488 *
1489 * \since 12
1490 */
1491 void *(*mapImage)(__DRIcontext *context, __DRIimage *image,
1492 int x0, int y0, int width, int height,
1493 unsigned int flags, int *stride, void **data);
1494
1495 /**
1496 * Unmap a previously mapped __DRIimage
1497 *
1498 * \since 12
1499 */
1500 void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);
1501
1502
1503 /**
1504 * Creates an image with implementation's favorite modifiers.
1505 *
1506 * This acts like createImage except there is a list of modifiers passed in
1507 * which the implementation may selectively use to create the DRIimage. The
1508 * result should be the implementation selects one modifier (perhaps it would
1509 * hold on to a few and later pick).
1510 *
1511 * The created image should be destroyed with destroyImage().
1512 *
1513 * Returns the new DRIimage. The chosen modifier can be obtained later on
1514 * and passed back to things like the kernel's AddFB2 interface.
1515 *
1516 * \sa __DRIimageRec::createImage
1517 *
1518 * \since 14
1519 */
1520 __DRIimage *(*createImageWithModifiers)(__DRIscreen *screen,
1521 int width, int height, int format,
1522 const uint64_t *modifiers,
1523 const unsigned int modifier_count,
1524 void *loaderPrivate);
1525
1526 /*
1527 * Like createImageFromDmaBufs, but takes also format modifiers.
1528 *
1529 * For EGL_EXT_image_dma_buf_import_modifiers.
1530 *
1531 * \since 15
1532 */
1533 __DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen,
1534 int width, int height, int fourcc,
1535 uint64_t modifier,
1536 int *fds, int num_fds,
1537 int *strides, int *offsets,
1538 enum __DRIYUVColorSpace color_space,
1539 enum __DRISampleRange sample_range,
1540 enum __DRIChromaSiting horiz_siting,
1541 enum __DRIChromaSiting vert_siting,
1542 unsigned *error,
1543 void *loaderPrivate);
1544
1545 /*
1546 * dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers.
1547 *
1548 * \param max Maximum number of formats that can be accomodated into
1549 * \param formats. If zero, no formats are returned -
1550 * instead, the driver returns the total number of
1551 * supported dmabuf formats in \param count.
1552 * \param formats Buffer to fill formats into.
1553 * \param count Count of formats returned, or, total number of
1554 * supported formats in case \param max is zero.
1555 *
1556 * Returns true on success.
1557 *
1558 * \since 15
1559 */
1560 GLboolean (*queryDmaBufFormats)(__DRIscreen *screen, int max,
1561 int *formats, int *count);
1562
1563 /*
1564 * dmabuf format modifier query for a given format to support
1565 * EGL_EXT_image_dma_buf_import_modifiers.
1566 *
1567 * \param fourcc The format to query modifiers for. If this format
1568 * is not supported by the driver, return false.
1569 * \param max Maximum number of modifiers that can be accomodated in
1570 * \param modifiers. If zero, no modifiers are returned -
1571 * instead, the driver returns the total number of
1572 * modifiers for \param format in \param count.
1573 * \param modifiers Buffer to fill modifiers into.
1574 * \param count Count of the modifiers returned, or, total number of
1575 * supported modifiers for \param fourcc in case
1576 * \param max is zero.
1577 *
1578 * Returns true upon success.
1579 *
1580 * \since 15
1581 */
1582 GLboolean (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc,
1583 int max, uint64_t *modifiers,
1584 unsigned int *external_only,
1585 int *count);
1586 };
1587
1588
1589 /**
1590 * This extension must be implemented by the loader and passed to the
1591 * driver at screen creation time. The EGLImage entry points in the
1592 * various client APIs take opaque EGLImage handles and use this
1593 * extension to map them to a __DRIimage. At version 1, this
1594 * extensions allows mapping EGLImage pointers to __DRIimage pointers,
1595 * but future versions could support other EGLImage-like, opaque types
1596 * with new lookup functions.
1597 */
1598 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
1599 #define __DRI_IMAGE_LOOKUP_VERSION 1
1600
1601 typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
1602 struct __DRIimageLookupExtensionRec {
1603 __DRIextension base;
1604
1605 __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
1606 void *loaderPrivate);
1607 };
1608
1609 /**
1610 * This extension allows for common DRI2 options
1611 */
1612 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
1613 #define __DRI2_CONFIG_QUERY_VERSION 1
1614
1615 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
1616 struct __DRI2configQueryExtensionRec {
1617 __DRIextension base;
1618
1619 int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);
1620 int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
1621 int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
1622 };
1623
1624 /**
1625 * Robust context driver extension.
1626 *
1627 * Existence of this extension means the driver can accept the
1628 * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
1629 * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
1630 * \c __DRIdri2ExtensionRec::createContextAttribs.
1631 */
1632 #define __DRI2_ROBUSTNESS "DRI_Robustness"
1633 #define __DRI2_ROBUSTNESS_VERSION 1
1634
1635 typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
1636 struct __DRIrobustnessExtensionRec {
1637 __DRIextension base;
1638 };
1639
1640 /**
1641 * No-error context driver extension.
1642 *
1643 * Existence of this extension means the driver can accept the
1644 * __DRI_CTX_FLAG_NO_ERROR flag.
1645 */
1646 #define __DRI2_NO_ERROR "DRI_NoError"
1647 #define __DRI2_NO_ERROR_VERSION 1
1648
1649 typedef struct __DRInoErrorExtensionRec {
1650 __DRIextension base;
1651 } __DRInoErrorExtension;
1652
1653 /**
1654 * DRI config options extension.
1655 *
1656 * This extension provides the XML string containing driver options for use by
1657 * the loader in supporting the driconf application.
1658 *
1659 * v2:
1660 * - Add the getXml getter function which allows the driver more flexibility in
1661 * how the XML is provided.
1662 * - Deprecate the direct xml pointer. It is only provided as a fallback for
1663 * older versions of libGL and must not be used by clients that are aware of
1664 * the newer version. Future driver versions may set it to NULL.
1665 */
1666 #define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
1667 #define __DRI_CONFIG_OPTIONS_VERSION 2
1668
1669 typedef struct __DRIconfigOptionsExtensionRec {
1670 __DRIextension base;
1671 const char *xml; /**< deprecated since v2, use getXml instead */
1672
1673 /**
1674 * Get an XML string that describes available driver options for use by a
1675 * config application.
1676 *
1677 * The returned string must be heap-allocated. The caller is responsible for
1678 * freeing it.
1679 */
1680 char *(*getXml)(const char *driver_name);
1681 } __DRIconfigOptionsExtension;
1682
1683 /**
1684 * This extension provides a driver vtable to a set of common driver helper
1685 * functions (driCoreExtension, driDRI2Extension) within the driver
1686 * implementation, as opposed to having to pass them through a global
1687 * variable.
1688 *
1689 * It is not intended to be public API to the actual loader, and the vtable
1690 * layout may change at any time.
1691 */
1692 #define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
1693 #define __DRI_DRIVER_VTABLE_VERSION 1
1694
1695 typedef struct __DRIDriverVtableExtensionRec {
1696 __DRIextension base;
1697 const struct __DriverAPIRec *vtable;
1698 } __DRIDriverVtableExtension;
1699
1700 /**
1701 * Query renderer driver extension
1702 *
1703 * This allows the window system layer (either EGL or GLX) to query aspects of
1704 * hardware and driver support without creating a context.
1705 */
1706 #define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
1707 #define __DRI2_RENDERER_QUERY_VERSION 1
1708
1709 #define __DRI2_RENDERER_VENDOR_ID 0x0000
1710 #define __DRI2_RENDERER_DEVICE_ID 0x0001
1711 #define __DRI2_RENDERER_VERSION 0x0002
1712 #define __DRI2_RENDERER_ACCELERATED 0x0003
1713 #define __DRI2_RENDERER_VIDEO_MEMORY 0x0004
1714 #define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005
1715 #define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006
1716 #define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007
1717 #define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008
1718 #define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009
1719 #define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a
1720 #define __DRI2_RENDERER_HAS_TEXTURE_3D 0x000b
1721 /* Whether there is an sRGB format support for every supported 32-bit UNORM
1722 * color format.
1723 */
1724 #define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c
1725
1726 typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
1727 struct __DRI2rendererQueryExtensionRec {
1728 __DRIextension base;
1729
1730 int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
1731 int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
1732 };
1733
1734 /**
1735 * Image Loader extension. Drivers use this to allocate color buffers
1736 */
1737
1738 enum __DRIimageBufferMask {
1739 __DRI_IMAGE_BUFFER_BACK = (1 << 0),
1740 __DRI_IMAGE_BUFFER_FRONT = (1 << 1)
1741 };
1742
1743 struct __DRIimageList {
1744 uint32_t image_mask;
1745 __DRIimage *back;
1746 __DRIimage *front;
1747 };
1748
1749 #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
1750 #define __DRI_IMAGE_LOADER_VERSION 2
1751
1752 struct __DRIimageLoaderExtensionRec {
1753 __DRIextension base;
1754
1755 /**
1756 * Allocate color buffers.
1757 *
1758 * \param driDrawable
1759 * \param width Width of allocated buffers
1760 * \param height Height of allocated buffers
1761 * \param format one of __DRI_IMAGE_FORMAT_*
1762 * \param stamp Address of variable to be updated when
1763 * getBuffers must be called again
1764 * \param loaderPrivate The loaderPrivate for driDrawable
1765 * \param buffer_mask Set of buffers to allocate
1766 * \param buffers Returned buffers
1767 */
1768 int (*getBuffers)(__DRIdrawable *driDrawable,
1769 unsigned int format,
1770 uint32_t *stamp,
1771 void *loaderPrivate,
1772 uint32_t buffer_mask,
1773 struct __DRIimageList *buffers);
1774
1775 /**
1776 * Flush pending front-buffer rendering
1777 *
1778 * Any rendering that has been performed to the
1779 * fake front will be flushed to the front
1780 *
1781 * \param driDrawable Drawable whose front-buffer is to be flushed
1782 * \param loaderPrivate Loader's private data that was previously passed
1783 * into __DRIdri2ExtensionRec::createNewDrawable
1784 */
1785 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
1786
1787 /**
1788 * Return a loader capability value. If the loader doesn't know the enum,
1789 * it will return 0.
1790 *
1791 * \since 2
1792 */
1793 unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
1794 };
1795
1796 /**
1797 * DRI extension.
1798 */
1799
1800 #define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"
1801 #define __DRI_IMAGE_DRIVER_VERSION 1
1802
1803 struct __DRIimageDriverExtensionRec {
1804 __DRIextension base;
1805
1806 /* Common DRI functions, shared with DRI2 */
1807 __DRIcreateNewScreen2Func createNewScreen2;
1808 __DRIcreateNewDrawableFunc createNewDrawable;
1809 __DRIcreateContextAttribsFunc createContextAttribs;
1810 __DRIgetAPIMaskFunc getAPIMask;
1811 };
1812
1813 /**
1814 * Background callable loader extension.
1815 *
1816 * Loaders expose this extension to indicate to drivers that they are capable
1817 * of handling callbacks from the driver's background drawing threads.
1818 */
1819 #define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"
1820 #define __DRI_BACKGROUND_CALLABLE_VERSION 1
1821
1822 typedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension;
1823 struct __DRIbackgroundCallableExtensionRec {
1824 __DRIextension base;
1825
1826 /**
1827 * Indicate that this thread is being used by the driver as a background
1828 * drawing thread which may make callbacks to the loader.
1829 *
1830 * \param loaderPrivate is the value that was passed to to the driver when
1831 * the context was created. This can be used by the loader to identify
1832 * which context any callbacks are associated with.
1833 *
1834 * If this function is called more than once from any given thread, each
1835 * subsequent call overrides the loaderPrivate data that was passed in the
1836 * previous call. The driver can take advantage of this to re-use a
1837 * background thread to perform drawing on behalf of multiple contexts.
1838 *
1839 * It is permissible for the driver to call this function from a
1840 * non-background thread (i.e. a thread that has already been bound to a
1841 * context using __DRIcoreExtensionRec::bindContext()); when this happens,
1842 * the \c loaderPrivate pointer must be equal to the pointer that was
1843 * passed to the driver when the currently bound context was created.
1844 *
1845 * This call should execute quickly enough that the driver can call it with
1846 * impunity whenever a background thread starts performing drawing
1847 * operations (e.g. it should just set a thread-local variable).
1848 */
1849 void (*setBackgroundContext)(void *loaderPrivate);
1850
1851 /**
1852 * Indicate that it is multithread safe to use glthread. For GLX/EGL
1853 * platforms using Xlib, that involves calling XInitThreads, before
1854 * opening an X display.
1855 *
1856 * Note: only supported if extension version is at least 2.
1857 *
1858 * \param loaderPrivate is the value that was passed to to the driver when
1859 * the context was created. This can be used by the loader to identify
1860 * which context any callbacks are associated with.
1861 */
1862 GLboolean (*isThreadSafe)(void *loaderPrivate);
1863 };
1864
1865 #endif