dri: add offset attribute and bump version of EGLImage extensions.
[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 1
344
345 #define __DRI2_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffllu
346
347 #define __DRI2_FENCE_FLAG_FLUSH_COMMANDS (1 << 0)
348
349 struct __DRI2fenceExtensionRec {
350 __DRIextension base;
351
352 /**
353 * Create and insert a fence into the command stream of the context.
354 */
355 void *(*create_fence)(__DRIcontext *ctx);
356
357 /**
358 * Get a fence associated with the OpenCL event object.
359 * This can be NULL, meaning that OpenCL interoperability is not supported.
360 */
361 void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event);
362
363 /**
364 * Destroy a fence.
365 */
366 void (*destroy_fence)(__DRIscreen *screen, void *fence);
367
368 /**
369 * This function waits and doesn't return until the fence is signalled
370 * or the timeout expires. It returns true if the fence has been signaled.
371 *
372 * \param ctx the context where commands are flushed
373 * \param fence the fence
374 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags
375 * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE
376 */
377 GLboolean (*client_wait_sync)(__DRIcontext *ctx, void *fence,
378 unsigned flags, uint64_t timeout);
379
380 /**
381 * This function enqueues a wait command into the command stream of
382 * the context and then returns. When the execution reaches the wait
383 * command, no further execution will be done in the context until
384 * the fence is signaled. This is a no-op if the device doesn't support
385 * parallel execution of contexts.
386 *
387 * \param ctx the context where the waiting is done
388 * \param fence the fence
389 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags that make
390 * sense with this function (right now there are none)
391 */
392 void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags);
393 };
394
395
396 /**
397 * Extension for API interop.
398 * See GL/mesa_glinterop.h.
399 */
400
401 #define __DRI2_INTEROP "DRI2_Interop"
402 #define __DRI2_INTEROP_VERSION 1
403
404 struct mesa_glinterop_device_info;
405 struct mesa_glinterop_export_in;
406 struct mesa_glinterop_export_out;
407
408 struct __DRI2interopExtensionRec {
409 __DRIextension base;
410
411 /** Same as MesaGLInterop*QueryDeviceInfo. */
412 int (*query_device_info)(__DRIcontext *ctx,
413 struct mesa_glinterop_device_info *out);
414
415 /** Same as MesaGLInterop*ExportObject. */
416 int (*export_object)(__DRIcontext *ctx,
417 struct mesa_glinterop_export_in *in,
418 struct mesa_glinterop_export_out *out);
419 };
420
421 /*@}*/
422
423 /**
424 * The following extensions describe loader features that the DRI
425 * driver can make use of. Some of these are mandatory, such as the
426 * getDrawableInfo extension for DRI and the DRI Loader extensions for
427 * DRI2, while others are optional, and if present allow the driver to
428 * expose certain features. The loader pass in a NULL terminated
429 * array of these extensions to the driver in the createNewScreen
430 * constructor.
431 */
432
433 typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
434 typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
435 typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
436 typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
437 typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
438
439
440 /**
441 * Callback to getDrawableInfo protocol
442 */
443 #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
444 #define __DRI_GET_DRAWABLE_INFO_VERSION 1
445 struct __DRIgetDrawableInfoExtensionRec {
446 __DRIextension base;
447
448 /**
449 * This function is used to get information about the position, size, and
450 * clip rects of a drawable.
451 */
452 GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
453 unsigned int * index, unsigned int * stamp,
454 int * x, int * y, int * width, int * height,
455 int * numClipRects, drm_clip_rect_t ** pClipRects,
456 int * backX, int * backY,
457 int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
458 void *loaderPrivate);
459 };
460
461 /**
462 * Callback to get system time for media stream counter extensions.
463 */
464 #define __DRI_SYSTEM_TIME "DRI_SystemTime"
465 #define __DRI_SYSTEM_TIME_VERSION 1
466 struct __DRIsystemTimeExtensionRec {
467 __DRIextension base;
468
469 /**
470 * Get the 64-bit unadjusted system time (UST).
471 */
472 int (*getUST)(int64_t * ust);
473
474 /**
475 * Get the media stream counter (MSC) rate.
476 *
477 * Matching the definition in GLX_OML_sync_control, this function returns
478 * the rate of the "media stream counter". In practical terms, this is
479 * the frame refresh rate of the display.
480 */
481 GLboolean (*getMSCRate)(__DRIdrawable *draw,
482 int32_t * numerator, int32_t * denominator,
483 void *loaderPrivate);
484 };
485
486 /**
487 * Damage reporting
488 */
489 #define __DRI_DAMAGE "DRI_Damage"
490 #define __DRI_DAMAGE_VERSION 1
491 struct __DRIdamageExtensionRec {
492 __DRIextension base;
493
494 /**
495 * Reports areas of the given drawable which have been modified by the
496 * driver.
497 *
498 * \param drawable which the drawing was done to.
499 * \param rects rectangles affected, with the drawable origin as the
500 * origin.
501 * \param x X offset of the drawable within the screen (used in the
502 * front_buffer case)
503 * \param y Y offset of the drawable within the screen.
504 * \param front_buffer boolean flag for whether the drawing to the
505 * drawable was actually done directly to the front buffer (instead
506 * of backing storage, for example)
507 * \param loaderPrivate the data passed in at createNewDrawable time
508 */
509 void (*reportDamage)(__DRIdrawable *draw,
510 int x, int y,
511 drm_clip_rect_t *rects, int num_rects,
512 GLboolean front_buffer,
513 void *loaderPrivate);
514 };
515
516 #define __DRI_SWRAST_IMAGE_OP_DRAW 1
517 #define __DRI_SWRAST_IMAGE_OP_CLEAR 2
518 #define __DRI_SWRAST_IMAGE_OP_SWAP 3
519
520 /**
521 * SWRast Loader extension.
522 */
523 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
524 #define __DRI_SWRAST_LOADER_VERSION 3
525 struct __DRIswrastLoaderExtensionRec {
526 __DRIextension base;
527
528 /*
529 * Drawable position and size
530 */
531 void (*getDrawableInfo)(__DRIdrawable *drawable,
532 int *x, int *y, int *width, int *height,
533 void *loaderPrivate);
534
535 /**
536 * Put image to drawable
537 */
538 void (*putImage)(__DRIdrawable *drawable, int op,
539 int x, int y, int width, int height,
540 char *data, void *loaderPrivate);
541
542 /**
543 * Get image from readable
544 */
545 void (*getImage)(__DRIdrawable *readable,
546 int x, int y, int width, int height,
547 char *data, void *loaderPrivate);
548
549 /**
550 * Put image to drawable
551 *
552 * \since 2
553 */
554 void (*putImage2)(__DRIdrawable *drawable, int op,
555 int x, int y, int width, int height, int stride,
556 char *data, void *loaderPrivate);
557
558 /**
559 * Put image to drawable
560 *
561 * \since 3
562 */
563 void (*getImage2)(__DRIdrawable *readable,
564 int x, int y, int width, int height, int stride,
565 char *data, void *loaderPrivate);
566 };
567
568 /**
569 * Invalidate loader extension. The presence of this extension
570 * indicates to the DRI driver that the loader will call invalidate in
571 * the __DRI2_FLUSH extension, whenever the needs to query for new
572 * buffers. This means that the DRI driver can drop the polling in
573 * glViewport().
574 *
575 * The extension doesn't provide any functionality, it's only use to
576 * indicate to the driver that it can use the new semantics. A DRI
577 * driver can use this to switch between the different semantics or
578 * just refuse to initialize if this extension isn't present.
579 */
580 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
581 #define __DRI_USE_INVALIDATE_VERSION 1
582
583 typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
584 struct __DRIuseInvalidateExtensionRec {
585 __DRIextension base;
586 };
587
588 /**
589 * The remaining extensions describe driver extensions, immediately
590 * available interfaces provided by the driver. To start using the
591 * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
592 * the extension you need in the array.
593 */
594 #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
595
596 /**
597 * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
598 * suffixed by "_drivername", allowing multiple drivers to be built into one
599 * library, and also giving the driver the chance to return a variable driver
600 * extensions struct depending on the driver name being loaded or any other
601 * system state.
602 *
603 * The function prototype is:
604 *
605 * const __DRIextension **__driDriverGetExtensions_drivername(void);
606 */
607 #define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
608
609 /**
610 * Tokens for __DRIconfig attribs. A number of attributes defined by
611 * GLX or EGL standards are not in the table, as they must be provided
612 * by the loader. For example, FBConfig ID or visual ID, drawable type.
613 */
614
615 #define __DRI_ATTRIB_BUFFER_SIZE 1
616 #define __DRI_ATTRIB_LEVEL 2
617 #define __DRI_ATTRIB_RED_SIZE 3
618 #define __DRI_ATTRIB_GREEN_SIZE 4
619 #define __DRI_ATTRIB_BLUE_SIZE 5
620 #define __DRI_ATTRIB_LUMINANCE_SIZE 6
621 #define __DRI_ATTRIB_ALPHA_SIZE 7
622 #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
623 #define __DRI_ATTRIB_DEPTH_SIZE 9
624 #define __DRI_ATTRIB_STENCIL_SIZE 10
625 #define __DRI_ATTRIB_ACCUM_RED_SIZE 11
626 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
627 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
628 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
629 #define __DRI_ATTRIB_SAMPLE_BUFFERS 15
630 #define __DRI_ATTRIB_SAMPLES 16
631 #define __DRI_ATTRIB_RENDER_TYPE 17
632 #define __DRI_ATTRIB_CONFIG_CAVEAT 18
633 #define __DRI_ATTRIB_CONFORMANT 19
634 #define __DRI_ATTRIB_DOUBLE_BUFFER 20
635 #define __DRI_ATTRIB_STEREO 21
636 #define __DRI_ATTRIB_AUX_BUFFERS 22
637 #define __DRI_ATTRIB_TRANSPARENT_TYPE 23
638 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
639 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
640 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
641 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
642 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
643 #define __DRI_ATTRIB_FLOAT_MODE 29
644 #define __DRI_ATTRIB_RED_MASK 30
645 #define __DRI_ATTRIB_GREEN_MASK 31
646 #define __DRI_ATTRIB_BLUE_MASK 32
647 #define __DRI_ATTRIB_ALPHA_MASK 33
648 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
649 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
650 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
651 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
652 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
653 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
654 #define __DRI_ATTRIB_SWAP_METHOD 40
655 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
656 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
657 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
658 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
659 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
660 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
661 #define __DRI_ATTRIB_YINVERTED 47
662 #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
663
664 /* __DRI_ATTRIB_RENDER_TYPE */
665 #define __DRI_ATTRIB_RGBA_BIT 0x01
666 #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
667 #define __DRI_ATTRIB_LUMINANCE_BIT 0x04
668 #define __DRI_ATTRIB_FLOAT_BIT 0x08
669 #define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10
670
671 /* __DRI_ATTRIB_CONFIG_CAVEAT */
672 #define __DRI_ATTRIB_SLOW_BIT 0x01
673 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
674
675 /* __DRI_ATTRIB_TRANSPARENT_TYPE */
676 #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
677 #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
678
679 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
680 #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
681 #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
682 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
683
684 /**
685 * This extension defines the core DRI functionality.
686 */
687 #define __DRI_CORE "DRI_Core"
688 #define __DRI_CORE_VERSION 1
689
690 struct __DRIcoreExtensionRec {
691 __DRIextension base;
692
693 __DRIscreen *(*createNewScreen)(int screen, int fd,
694 unsigned int sarea_handle,
695 const __DRIextension **extensions,
696 const __DRIconfig ***driverConfigs,
697 void *loaderPrivate);
698
699 void (*destroyScreen)(__DRIscreen *screen);
700
701 const __DRIextension **(*getExtensions)(__DRIscreen *screen);
702
703 int (*getConfigAttrib)(const __DRIconfig *config,
704 unsigned int attrib,
705 unsigned int *value);
706
707 int (*indexConfigAttrib)(const __DRIconfig *config, int index,
708 unsigned int *attrib, unsigned int *value);
709
710 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
711 const __DRIconfig *config,
712 unsigned int drawable_id,
713 unsigned int head,
714 void *loaderPrivate);
715
716 void (*destroyDrawable)(__DRIdrawable *drawable);
717
718 void (*swapBuffers)(__DRIdrawable *drawable);
719
720 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
721 const __DRIconfig *config,
722 __DRIcontext *shared,
723 void *loaderPrivate);
724
725 int (*copyContext)(__DRIcontext *dest,
726 __DRIcontext *src,
727 unsigned long mask);
728
729 void (*destroyContext)(__DRIcontext *context);
730
731 int (*bindContext)(__DRIcontext *ctx,
732 __DRIdrawable *pdraw,
733 __DRIdrawable *pread);
734
735 int (*unbindContext)(__DRIcontext *ctx);
736 };
737
738 /**
739 * Stored version of some component (i.e., server-side DRI module, kernel-side
740 * DRM, etc.).
741 *
742 * \todo
743 * There are several data structures that explicitly store a major version,
744 * minor version, and patch level. These structures should be modified to
745 * have a \c __DRIversionRec instead.
746 */
747 struct __DRIversionRec {
748 int major; /**< Major version number. */
749 int minor; /**< Minor version number. */
750 int patch; /**< Patch-level. */
751 };
752
753 /**
754 * Framebuffer information record. Used by libGL to communicate information
755 * about the framebuffer to the driver's \c __driCreateNewScreen function.
756 *
757 * In XFree86, most of this information is derrived from data returned by
758 * calling \c XF86DRIGetDeviceInfo.
759 *
760 * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
761 * __driUtilCreateNewScreen CallCreateNewScreen
762 *
763 * \bug This structure could be better named.
764 */
765 struct __DRIframebufferRec {
766 unsigned char *base; /**< Framebuffer base address in the CPU's
767 * address space. This value is calculated by
768 * calling \c drmMap on the framebuffer handle
769 * returned by \c XF86DRIGetDeviceInfo (or a
770 * similar function).
771 */
772 int size; /**< Framebuffer size, in bytes. */
773 int stride; /**< Number of bytes from one line to the next. */
774 int width; /**< Pixel width of the framebuffer. */
775 int height; /**< Pixel height of the framebuffer. */
776 int dev_priv_size; /**< Size of the driver's dev-priv structure. */
777 void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
778 };
779
780
781 /**
782 * This extension provides alternative screen, drawable and context
783 * constructors for legacy DRI functionality. This is used in
784 * conjunction with the core extension.
785 */
786 #define __DRI_LEGACY "DRI_Legacy"
787 #define __DRI_LEGACY_VERSION 1
788
789 struct __DRIlegacyExtensionRec {
790 __DRIextension base;
791
792 __DRIscreen *(*createNewScreen)(int screen,
793 const __DRIversion *ddx_version,
794 const __DRIversion *dri_version,
795 const __DRIversion *drm_version,
796 const __DRIframebuffer *frame_buffer,
797 void *pSAREA, int fd,
798 const __DRIextension **extensions,
799 const __DRIconfig ***driver_configs,
800 void *loaderPrivate);
801
802 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
803 const __DRIconfig *config,
804 drm_drawable_t hwDrawable,
805 int renderType, const int *attrs,
806 void *loaderPrivate);
807
808 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
809 const __DRIconfig *config,
810 int render_type,
811 __DRIcontext *shared,
812 drm_context_t hwContext,
813 void *loaderPrivate);
814 };
815
816 /**
817 * This extension provides alternative screen, drawable and context
818 * constructors for swrast DRI functionality. This is used in
819 * conjunction with the core extension.
820 */
821 #define __DRI_SWRAST "DRI_SWRast"
822 #define __DRI_SWRAST_VERSION 4
823
824 struct __DRIswrastExtensionRec {
825 __DRIextension base;
826
827 __DRIscreen *(*createNewScreen)(int screen,
828 const __DRIextension **extensions,
829 const __DRIconfig ***driver_configs,
830 void *loaderPrivate);
831
832 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
833 const __DRIconfig *config,
834 void *loaderPrivate);
835
836 /* Since version 2 */
837 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
838 int api,
839 const __DRIconfig *config,
840 __DRIcontext *shared,
841 void *data);
842
843 /**
844 * Create a context for a particular API with a set of attributes
845 *
846 * \since version 3
847 *
848 * \sa __DRIdri2ExtensionRec::createContextAttribs
849 */
850 __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
851 int api,
852 const __DRIconfig *config,
853 __DRIcontext *shared,
854 unsigned num_attribs,
855 const uint32_t *attribs,
856 unsigned *error,
857 void *loaderPrivate);
858
859 /**
860 * createNewScreen() with the driver extensions passed in.
861 *
862 * \since version 4
863 */
864 __DRIscreen *(*createNewScreen2)(int screen,
865 const __DRIextension **loader_extensions,
866 const __DRIextension **driver_extensions,
867 const __DRIconfig ***driver_configs,
868 void *loaderPrivate);
869
870 };
871
872 /** Common DRI function definitions, shared among DRI2 and Image extensions
873 */
874
875 typedef __DRIscreen *
876 (*__DRIcreateNewScreen2Func)(int screen, int fd,
877 const __DRIextension **extensions,
878 const __DRIextension **driver_extensions,
879 const __DRIconfig ***driver_configs,
880 void *loaderPrivate);
881
882 typedef __DRIdrawable *
883 (*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
884 const __DRIconfig *config,
885 void *loaderPrivate);
886
887 typedef __DRIcontext *
888 (*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
889 int api,
890 const __DRIconfig *config,
891 __DRIcontext *shared,
892 unsigned num_attribs,
893 const uint32_t *attribs,
894 unsigned *error,
895 void *loaderPrivate);
896
897 typedef unsigned int
898 (*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
899
900 /**
901 * DRI2 Loader extension.
902 */
903 #define __DRI_BUFFER_FRONT_LEFT 0
904 #define __DRI_BUFFER_BACK_LEFT 1
905 #define __DRI_BUFFER_FRONT_RIGHT 2
906 #define __DRI_BUFFER_BACK_RIGHT 3
907 #define __DRI_BUFFER_DEPTH 4
908 #define __DRI_BUFFER_STENCIL 5
909 #define __DRI_BUFFER_ACCUM 6
910 #define __DRI_BUFFER_FAKE_FRONT_LEFT 7
911 #define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
912 #define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
913 #define __DRI_BUFFER_HIZ 10
914
915 /* Inofficial and for internal use. Increase when adding a new buffer token. */
916 #define __DRI_BUFFER_COUNT 11
917
918 struct __DRIbufferRec {
919 unsigned int attachment;
920 unsigned int name;
921 unsigned int pitch;
922 unsigned int cpp;
923 unsigned int flags;
924 };
925
926 #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
927 #define __DRI_DRI2_LOADER_VERSION 3
928 struct __DRIdri2LoaderExtensionRec {
929 __DRIextension base;
930
931 __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
932 int *width, int *height,
933 unsigned int *attachments, int count,
934 int *out_count, void *loaderPrivate);
935
936 /**
937 * Flush pending front-buffer rendering
938 *
939 * Any rendering that has been performed to the
940 * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
941 * \c __DRI_BUFFER_FRONT_LEFT.
942 *
943 * \param driDrawable Drawable whose front-buffer is to be flushed
944 * \param loaderPrivate Loader's private data that was previously passed
945 * into __DRIdri2ExtensionRec::createNewDrawable
946 *
947 * \since 2
948 */
949 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
950
951
952 /**
953 * Get list of buffers from the server
954 *
955 * Gets a list of buffer for the specified set of attachments. Unlike
956 * \c ::getBuffers, this function takes a list of attachments paired with
957 * opaque \c unsigned \c int value describing the format of the buffer.
958 * It is the responsibility of the caller to know what the service that
959 * allocates the buffers will expect to receive for the format.
960 *
961 * \param driDrawable Drawable whose buffers are being queried.
962 * \param width Output where the width of the buffers is stored.
963 * \param height Output where the height of the buffers is stored.
964 * \param attachments List of pairs of attachment ID and opaque format
965 * requested for the drawable.
966 * \param count Number of attachment / format pairs stored in
967 * \c attachments.
968 * \param loaderPrivate Loader's private data that was previously passed
969 * into __DRIdri2ExtensionRec::createNewDrawable.
970 *
971 * \since 3
972 */
973 __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
974 int *width, int *height,
975 unsigned int *attachments, int count,
976 int *out_count, void *loaderPrivate);
977 };
978
979 /**
980 * This extension provides alternative screen, drawable and context
981 * constructors for DRI2.
982 */
983 #define __DRI_DRI2 "DRI_DRI2"
984 #define __DRI_DRI2_VERSION 4
985
986 #define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
987 #define __DRI_API_GLES 1 /**< OpenGL ES 1.x */
988 #define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */
989 #define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
990 #define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */
991
992 #define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
993 #define __DRI_CTX_ATTRIB_MINOR_VERSION 1
994 #define __DRI_CTX_ATTRIB_FLAGS 2
995
996 /**
997 * \requires __DRI2_ROBUSTNESS.
998 */
999 #define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
1000
1001 #define __DRI_CTX_FLAG_DEBUG 0x00000001
1002 #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
1003
1004 /**
1005 * \requires __DRI2_ROBUSTNESS.
1006 */
1007 #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004
1008
1009 /**
1010 * \name Context reset strategies.
1011 */
1012 /*@{*/
1013 #define __DRI_CTX_RESET_NO_NOTIFICATION 0
1014 #define __DRI_CTX_RESET_LOSE_CONTEXT 1
1015 /*@}*/
1016
1017 /**
1018 * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
1019 */
1020 /*@{*/
1021 /** Success! */
1022 #define __DRI_CTX_ERROR_SUCCESS 0
1023
1024 /** Memory allocation failure */
1025 #define __DRI_CTX_ERROR_NO_MEMORY 1
1026
1027 /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
1028 #define __DRI_CTX_ERROR_BAD_API 2
1029
1030 /** Client requested an API version that the driver can't do. */
1031 #define __DRI_CTX_ERROR_BAD_VERSION 3
1032
1033 /** Client requested a flag or combination of flags the driver can't do. */
1034 #define __DRI_CTX_ERROR_BAD_FLAG 4
1035
1036 /** Client requested an attribute the driver doesn't understand. */
1037 #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
1038
1039 /** Client requested a flag the driver doesn't understand. */
1040 #define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
1041 /*@}*/
1042
1043 struct __DRIdri2ExtensionRec {
1044 __DRIextension base;
1045
1046 __DRIscreen *(*createNewScreen)(int screen, int fd,
1047 const __DRIextension **extensions,
1048 const __DRIconfig ***driver_configs,
1049 void *loaderPrivate);
1050
1051 __DRIcreateNewDrawableFunc createNewDrawable;
1052 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
1053 const __DRIconfig *config,
1054 __DRIcontext *shared,
1055 void *loaderPrivate);
1056
1057 /* Since version 2 */
1058 __DRIgetAPIMaskFunc getAPIMask;
1059
1060 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
1061 int api,
1062 const __DRIconfig *config,
1063 __DRIcontext *shared,
1064 void *data);
1065
1066 __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
1067 unsigned int attachment,
1068 unsigned int format,
1069 int width,
1070 int height);
1071 void (*releaseBuffer)(__DRIscreen *screen,
1072 __DRIbuffer *buffer);
1073
1074 /**
1075 * Create a context for a particular API with a set of attributes
1076 *
1077 * \since version 3
1078 *
1079 * \sa __DRIswrastExtensionRec::createContextAttribs
1080 */
1081 __DRIcreateContextAttribsFunc createContextAttribs;
1082
1083 /**
1084 * createNewScreen with the driver's extension list passed in.
1085 *
1086 * \since version 4
1087 */
1088 __DRIcreateNewScreen2Func createNewScreen2;
1089 };
1090
1091
1092 /**
1093 * This extension provides functionality to enable various EGLImage
1094 * extensions.
1095 */
1096 #define __DRI_IMAGE "DRI_IMAGE"
1097 #define __DRI_IMAGE_VERSION 13
1098
1099 /**
1100 * These formats correspond to the similarly named MESA_FORMAT_*
1101 * tokens, except in the native endian of the CPU. For example, on
1102 * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
1103 * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
1104 *
1105 * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
1106 * by the driver (YUV planar formats) but serve as a base image for
1107 * creating sub-images for the different planes within the image.
1108 *
1109 * R8, GR88 and NONE should not be used with createImageFormName or
1110 * createImage, and are returned by query from sub images created with
1111 * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
1112 */
1113 #define __DRI_IMAGE_FORMAT_RGB565 0x1001
1114 #define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
1115 #define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
1116 #define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
1117 #define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
1118 #define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
1119 #define __DRI_IMAGE_FORMAT_GR88 0x1007
1120 #define __DRI_IMAGE_FORMAT_NONE 0x1008
1121 #define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
1122 #define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
1123 #define __DRI_IMAGE_FORMAT_SARGB8 0x100b
1124
1125 #define __DRI_IMAGE_USE_SHARE 0x0001
1126 #define __DRI_IMAGE_USE_SCANOUT 0x0002
1127 #define __DRI_IMAGE_USE_CURSOR 0x0004 /* Depricated */
1128 #define __DRI_IMAGE_USE_LINEAR 0x0008
1129 /* The buffer will only be read by an external process after SwapBuffers,
1130 * in contrary to gbm buffers, front buffers and fake front buffers, which
1131 * could be read after a flush."
1132 */
1133 #define __DRI_IMAGE_USE_BACKBUFFER 0x0010
1134
1135
1136 #define __DRI_IMAGE_TRANSFER_READ 0x1
1137 #define __DRI_IMAGE_TRANSFER_WRITE 0x2
1138 #define __DRI_IMAGE_TRANSFER_READ_WRITE \
1139 (__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)
1140
1141 /**
1142 * Four CC formats that matches with WL_DRM_FORMAT_* from wayland_drm.h,
1143 * GBM_FORMAT_* from gbm.h, and DRM_FORMAT_* from drm_fourcc.h. Used with
1144 * createImageFromNames.
1145 *
1146 * \since 5
1147 */
1148
1149 #define __DRI_IMAGE_FOURCC_R8 0x20203852
1150 #define __DRI_IMAGE_FOURCC_GR88 0x38385247
1151 #define __DRI_IMAGE_FOURCC_RGB565 0x36314752
1152 #define __DRI_IMAGE_FOURCC_ARGB8888 0x34325241
1153 #define __DRI_IMAGE_FOURCC_XRGB8888 0x34325258
1154 #define __DRI_IMAGE_FOURCC_ABGR8888 0x34324241
1155 #define __DRI_IMAGE_FOURCC_XBGR8888 0x34324258
1156 #define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258
1157 #define __DRI_IMAGE_FOURCC_YUV410 0x39565559
1158 #define __DRI_IMAGE_FOURCC_YUV411 0x31315559
1159 #define __DRI_IMAGE_FOURCC_YUV420 0x32315559
1160 #define __DRI_IMAGE_FOURCC_YUV422 0x36315559
1161 #define __DRI_IMAGE_FOURCC_YUV444 0x34325559
1162 #define __DRI_IMAGE_FOURCC_NV12 0x3231564e
1163 #define __DRI_IMAGE_FOURCC_NV16 0x3631564e
1164 #define __DRI_IMAGE_FOURCC_YUYV 0x56595559
1165
1166 #define __DRI_IMAGE_FOURCC_YVU410 0x39555659
1167 #define __DRI_IMAGE_FOURCC_YVU411 0x31315659
1168 #define __DRI_IMAGE_FOURCC_YVU420 0x32315659
1169 #define __DRI_IMAGE_FOURCC_YVU422 0x36315659
1170 #define __DRI_IMAGE_FOURCC_YVU444 0x34325659
1171
1172 /**
1173 * Queryable on images created by createImageFromNames.
1174 *
1175 * RGB and RGBA are may be usable directly as images but its still
1176 * recommended to call fromPlanar with plane == 0.
1177 *
1178 * Y_U_V, Y_UV and Y_XUXV all requires call to fromPlanar to create
1179 * usable sub-images, sampling from images return raw YUV data and
1180 * color conversion needs to be done in the shader.
1181 *
1182 * \since 5
1183 */
1184
1185 #define __DRI_IMAGE_COMPONENTS_RGB 0x3001
1186 #define __DRI_IMAGE_COMPONENTS_RGBA 0x3002
1187 #define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
1188 #define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
1189 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
1190 #define __DRI_IMAGE_COMPONENTS_R 0x3006
1191 #define __DRI_IMAGE_COMPONENTS_RG 0x3007
1192
1193
1194 /**
1195 * queryImage attributes
1196 */
1197
1198 #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
1199 #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
1200 #define __DRI_IMAGE_ATTRIB_NAME 0x2002
1201 #define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
1202 #define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */
1203 #define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005
1204 #define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */
1205 #define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions
1206 * 7+. Each query will return a
1207 * new fd. */
1208 #define __DRI_IMAGE_ATTRIB_FOURCC 0x2008 /* available in versions 11 */
1209 #define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */
1210
1211 #define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
1212
1213 enum __DRIYUVColorSpace {
1214 __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
1215 __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
1216 __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
1217 __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
1218 };
1219
1220 enum __DRISampleRange {
1221 __DRI_YUV_RANGE_UNDEFINED = 0,
1222 __DRI_YUV_FULL_RANGE = 0x3282,
1223 __DRI_YUV_NARROW_RANGE = 0x3283
1224 };
1225
1226 enum __DRIChromaSiting {
1227 __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
1228 __DRI_YUV_CHROMA_SITING_0 = 0x3284,
1229 __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
1230 };
1231
1232 /**
1233 * \name Reasons that __DRIimageExtensionRec::createImageFromTexture or
1234 * __DRIimageExtensionRec::createImageFromDmaBufs might fail
1235 */
1236 /*@{*/
1237 /** Success! */
1238 #define __DRI_IMAGE_ERROR_SUCCESS 0
1239
1240 /** Memory allocation failure */
1241 #define __DRI_IMAGE_ERROR_BAD_ALLOC 1
1242
1243 /** Client requested an invalid attribute */
1244 #define __DRI_IMAGE_ERROR_BAD_MATCH 2
1245
1246 /** Client requested an invalid texture object */
1247 #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
1248
1249 /** Client requested an invalid pitch and/or offset */
1250 #define __DRI_IMAGE_ERROR_BAD_ACCESS 4
1251 /*@}*/
1252
1253 /**
1254 * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
1255 */
1256 /*@{*/
1257 #define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
1258 /*@}*/
1259
1260 /**
1261 * blitImage flags
1262 */
1263
1264 #define __BLIT_FLAG_FLUSH 0x0001
1265 #define __BLIT_FLAG_FINISH 0x0002
1266
1267 typedef struct __DRIimageRec __DRIimage;
1268 typedef struct __DRIimageExtensionRec __DRIimageExtension;
1269 struct __DRIimageExtensionRec {
1270 __DRIextension base;
1271
1272 __DRIimage *(*createImageFromName)(__DRIscreen *screen,
1273 int width, int height, int format,
1274 int name, int pitch,
1275 void *loaderPrivate);
1276
1277 __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
1278 int renderbuffer,
1279 void *loaderPrivate);
1280
1281 void (*destroyImage)(__DRIimage *image);
1282
1283 __DRIimage *(*createImage)(__DRIscreen *screen,
1284 int width, int height, int format,
1285 unsigned int use,
1286 void *loaderPrivate);
1287
1288 GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
1289
1290 /**
1291 * The new __DRIimage will share the content with the old one, see dup(2).
1292 */
1293 __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
1294
1295 /**
1296 * Validate that a __DRIimage can be used a certain way.
1297 *
1298 * \since 2
1299 */
1300 GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
1301
1302 /**
1303 * Unlike createImageFromName __DRI_IMAGE_FORMAT is not but instead
1304 * __DRI_IMAGE_FOURCC and strides are in bytes not pixels. Stride is
1305 * also per block and not per pixel (for non-RGB, see gallium blocks).
1306 *
1307 * \since 5
1308 */
1309 __DRIimage *(*createImageFromNames)(__DRIscreen *screen,
1310 int width, int height, int fourcc,
1311 int *names, int num_names,
1312 int *strides, int *offsets,
1313 void *loaderPrivate);
1314
1315 /**
1316 * Create an image out of a sub-region of a parent image. This
1317 * entry point lets us create individual __DRIimages for different
1318 * planes in a planar buffer (typically yuv), for example. While a
1319 * sub-image shares the underlying buffer object with the parent
1320 * image and other sibling sub-images, the life times of parent and
1321 * sub-images are not dependent. Destroying the parent or a
1322 * sub-image doesn't affect other images. The underlying buffer
1323 * object is free when no __DRIimage remains that references it.
1324 *
1325 * Sub-images may overlap, but rendering to overlapping sub-images
1326 * is undefined.
1327 *
1328 * \since 5
1329 */
1330 __DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
1331 void *loaderPrivate);
1332
1333 /**
1334 * Create image from texture.
1335 *
1336 * \since 6
1337 */
1338 __DRIimage *(*createImageFromTexture)(__DRIcontext *context,
1339 int target,
1340 unsigned texture,
1341 int depth,
1342 int level,
1343 unsigned *error,
1344 void *loaderPrivate);
1345 /**
1346 * Like createImageFromNames, but takes a prime fd instead.
1347 *
1348 * \since 7
1349 */
1350 __DRIimage *(*createImageFromFds)(__DRIscreen *screen,
1351 int width, int height, int fourcc,
1352 int *fds, int num_fds,
1353 int *strides, int *offsets,
1354 void *loaderPrivate);
1355
1356 /**
1357 * Like createImageFromFds, but takes additional attributes.
1358 *
1359 * For EGL_EXT_image_dma_buf_import.
1360 *
1361 * \since 8
1362 */
1363 __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
1364 int width, int height, int fourcc,
1365 int *fds, int num_fds,
1366 int *strides, int *offsets,
1367 enum __DRIYUVColorSpace color_space,
1368 enum __DRISampleRange sample_range,
1369 enum __DRIChromaSiting horiz_siting,
1370 enum __DRIChromaSiting vert_siting,
1371 unsigned *error,
1372 void *loaderPrivate);
1373
1374 /**
1375 * Blit a part of a __DRIimage to another and flushes
1376 *
1377 * flush_flag:
1378 * 0: no flush
1379 * __BLIT_FLAG_FLUSH: flush after the blit operation
1380 * __BLIT_FLAG_FINISH: flush and wait the blit finished
1381 *
1382 * \since 9
1383 */
1384 void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
1385 int dstx0, int dsty0, int dstwidth, int dstheight,
1386 int srcx0, int srcy0, int srcwidth, int srcheight,
1387 int flush_flag);
1388
1389 /**
1390 * Query for general capabilities of the driver that concern
1391 * buffer sharing and image importing.
1392 *
1393 * \since 10
1394 */
1395 int (*getCapabilities)(__DRIscreen *screen);
1396
1397 /**
1398 * Returns a map of the specified region of a __DRIimage for the specified usage.
1399 *
1400 * flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the
1401 * mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ
1402 * is not included in the flags, the buffer content at map time is
1403 * undefined. Users wanting to modify the mapping must include
1404 * __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not
1405 * included, behaviour when writing the mapping is undefined.
1406 *
1407 * Returns the byte stride in *stride, and an opaque pointer to data
1408 * tracking the mapping in **data, which must be passed to unmapImage().
1409 *
1410 * \since 12
1411 */
1412 void *(*mapImage)(__DRIcontext *context, __DRIimage *image,
1413 int x0, int y0, int width, int height,
1414 unsigned int flags, int *stride, void **data);
1415
1416 /**
1417 * Unmap a previously mapped __DRIimage
1418 *
1419 * \since 12
1420 */
1421 void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);
1422
1423 };
1424
1425
1426 /**
1427 * This extension must be implemented by the loader and passed to the
1428 * driver at screen creation time. The EGLImage entry points in the
1429 * various client APIs take opaque EGLImage handles and use this
1430 * extension to map them to a __DRIimage. At version 1, this
1431 * extensions allows mapping EGLImage pointers to __DRIimage pointers,
1432 * but future versions could support other EGLImage-like, opaque types
1433 * with new lookup functions.
1434 */
1435 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
1436 #define __DRI_IMAGE_LOOKUP_VERSION 1
1437
1438 typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
1439 struct __DRIimageLookupExtensionRec {
1440 __DRIextension base;
1441
1442 __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
1443 void *loaderPrivate);
1444 };
1445
1446 /**
1447 * This extension allows for common DRI2 options
1448 */
1449 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
1450 #define __DRI2_CONFIG_QUERY_VERSION 1
1451
1452 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
1453 struct __DRI2configQueryExtensionRec {
1454 __DRIextension base;
1455
1456 int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);
1457 int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
1458 int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
1459 };
1460
1461 /**
1462 * Robust context driver extension.
1463 *
1464 * Existence of this extension means the driver can accept the
1465 * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
1466 * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
1467 * \c __DRIdri2ExtensionRec::createContextAttribs.
1468 */
1469 #define __DRI2_ROBUSTNESS "DRI_Robustness"
1470 #define __DRI2_ROBUSTNESS_VERSION 1
1471
1472 typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
1473 struct __DRIrobustnessExtensionRec {
1474 __DRIextension base;
1475 };
1476
1477 /**
1478 * DRI config options extension.
1479 *
1480 * This extension provides the XML string containing driver options for use by
1481 * the loader in supporting the driconf application.
1482 */
1483 #define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
1484 #define __DRI_CONFIG_OPTIONS_VERSION 1
1485
1486 typedef struct __DRIconfigOptionsExtensionRec {
1487 __DRIextension base;
1488 const char *xml;
1489 } __DRIconfigOptionsExtension;
1490
1491 /**
1492 * This extension provides a driver vtable to a set of common driver helper
1493 * functions (driCoreExtension, driDRI2Extension) within the driver
1494 * implementation, as opposed to having to pass them through a global
1495 * variable.
1496 *
1497 * It is not intended to be public API to the actual loader, and the vtable
1498 * layout may change at any time.
1499 */
1500 #define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
1501 #define __DRI_DRIVER_VTABLE_VERSION 1
1502
1503 typedef struct __DRIDriverVtableExtensionRec {
1504 __DRIextension base;
1505 const struct __DriverAPIRec *vtable;
1506 } __DRIDriverVtableExtension;
1507
1508 /**
1509 * Query renderer driver extension
1510 *
1511 * This allows the window system layer (either EGL or GLX) to query aspects of
1512 * hardware and driver support without creating a context.
1513 */
1514 #define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
1515 #define __DRI2_RENDERER_QUERY_VERSION 1
1516
1517 #define __DRI2_RENDERER_VENDOR_ID 0x0000
1518 #define __DRI2_RENDERER_DEVICE_ID 0x0001
1519 #define __DRI2_RENDERER_VERSION 0x0002
1520 #define __DRI2_RENDERER_ACCELERATED 0x0003
1521 #define __DRI2_RENDERER_VIDEO_MEMORY 0x0004
1522 #define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005
1523 #define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006
1524 #define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007
1525 #define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008
1526 #define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009
1527 #define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a
1528 #define __DRI2_RENDERER_HAS_TEXTURE_3D 0x000b
1529 /* Whether there is an sRGB format support for every supported 32-bit UNORM
1530 * color format.
1531 */
1532 #define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c
1533
1534 typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
1535 struct __DRI2rendererQueryExtensionRec {
1536 __DRIextension base;
1537
1538 int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
1539 int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
1540 };
1541
1542 /**
1543 * Image Loader extension. Drivers use this to allocate color buffers
1544 */
1545
1546 enum __DRIimageBufferMask {
1547 __DRI_IMAGE_BUFFER_BACK = (1 << 0),
1548 __DRI_IMAGE_BUFFER_FRONT = (1 << 1)
1549 };
1550
1551 struct __DRIimageList {
1552 uint32_t image_mask;
1553 __DRIimage *back;
1554 __DRIimage *front;
1555 };
1556
1557 #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
1558 #define __DRI_IMAGE_LOADER_VERSION 1
1559
1560 struct __DRIimageLoaderExtensionRec {
1561 __DRIextension base;
1562
1563 /**
1564 * Allocate color buffers.
1565 *
1566 * \param driDrawable
1567 * \param width Width of allocated buffers
1568 * \param height Height of allocated buffers
1569 * \param format one of __DRI_IMAGE_FORMAT_*
1570 * \param stamp Address of variable to be updated when
1571 * getBuffers must be called again
1572 * \param loaderPrivate The loaderPrivate for driDrawable
1573 * \param buffer_mask Set of buffers to allocate
1574 * \param buffers Returned buffers
1575 */
1576 int (*getBuffers)(__DRIdrawable *driDrawable,
1577 unsigned int format,
1578 uint32_t *stamp,
1579 void *loaderPrivate,
1580 uint32_t buffer_mask,
1581 struct __DRIimageList *buffers);
1582
1583 /**
1584 * Flush pending front-buffer rendering
1585 *
1586 * Any rendering that has been performed to the
1587 * fake front will be flushed to the front
1588 *
1589 * \param driDrawable Drawable whose front-buffer is to be flushed
1590 * \param loaderPrivate Loader's private data that was previously passed
1591 * into __DRIdri2ExtensionRec::createNewDrawable
1592 */
1593 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
1594 };
1595
1596 /**
1597 * DRI extension.
1598 */
1599
1600 #define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"
1601 #define __DRI_IMAGE_DRIVER_VERSION 1
1602
1603 struct __DRIimageDriverExtensionRec {
1604 __DRIextension base;
1605
1606 /* Common DRI functions, shared with DRI2 */
1607 __DRIcreateNewScreen2Func createNewScreen2;
1608 __DRIcreateNewDrawableFunc createNewDrawable;
1609 __DRIcreateContextAttribsFunc createContextAttribs;
1610 __DRIgetAPIMaskFunc getAPIMask;
1611 };
1612
1613 #endif