dri_interface: add an interface for fences
[mesa.git] / include / GL / internal / dri_interface.h
1 /*
2 * Copyright 1998-1999 Precision Insight, Inc., Cedar Park, Texas.
3 * Copyright 2007-2008 Red Hat, Inc.
4 * (C) Copyright IBM Corporation 2004
5 * All Rights Reserved.
6 *
7 * Permission is hereby granted, free of charge, to any person obtaining a
8 * copy of this software and associated documentation files (the "Software"),
9 * to deal in the Software without restriction, including without limitation
10 * on the rights to use, copy, modify, merge, publish, distribute, sub
11 * license, and/or sell copies of the Software, and to permit persons to whom
12 * the Software is furnished to do so, subject to the following conditions:
13 *
14 * The above copyright notice and this permission notice (including the next
15 * paragraph) shall be included in all copies or substantial portions of the
16 * Software.
17 *
18 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
19 * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
20 * FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO EVENT SHALL
21 * THE COPYRIGHT HOLDERS AND/OR THEIR SUPPLIERS BE LIABLE FOR ANY CLAIM,
22 * DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
23 * OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE
24 * USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27 /**
28 * \file dri_interface.h
29 *
30 * This file contains all the types and functions that define the interface
31 * between a DRI driver and driver loader. Currently, the most common driver
32 * loader is the XFree86 libGL.so. However, other loaders do exist, and in
33 * the future the server-side libglx.a will also be a loader.
34 *
35 * \author Kevin E. Martin <kevin@precisioninsight.com>
36 * \author Ian Romanick <idr@us.ibm.com>
37 * \author Kristian Høgsberg <krh@redhat.com>
38 */
39
40 #ifndef DRI_INTERFACE_H
41 #define DRI_INTERFACE_H
42
43 /* For archs with no drm.h */
44 #if defined(__APPLE__) || defined(__CYGWIN__) || defined(__GNU__)
45 #ifndef __NOT_HAVE_DRM_H
46 #define __NOT_HAVE_DRM_H
47 #endif
48 #endif
49
50 #ifndef __NOT_HAVE_DRM_H
51 #include <drm.h>
52 #else
53 typedef unsigned int drm_context_t;
54 typedef unsigned int drm_drawable_t;
55 typedef struct drm_clip_rect drm_clip_rect_t;
56 #endif
57
58 /**
59 * \name DRI interface structures
60 *
61 * The following structures define the interface between the GLX client
62 * side library and the DRI (direct rendering infrastructure).
63 */
64 /*@{*/
65 typedef struct __DRIdisplayRec __DRIdisplay;
66 typedef struct __DRIscreenRec __DRIscreen;
67 typedef struct __DRIcontextRec __DRIcontext;
68 typedef struct __DRIdrawableRec __DRIdrawable;
69 typedef struct __DRIconfigRec __DRIconfig;
70 typedef struct __DRIframebufferRec __DRIframebuffer;
71 typedef struct __DRIversionRec __DRIversion;
72
73 typedef struct __DRIcoreExtensionRec __DRIcoreExtension;
74 typedef struct __DRIextensionRec __DRIextension;
75 typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
76 typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
77 typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
78 typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
79 typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
80 typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;
81 typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;
82 typedef struct __DRIswrastExtensionRec __DRIswrastExtension;
83 typedef struct __DRIbufferRec __DRIbuffer;
84 typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;
85 typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;
86 typedef struct __DRI2flushExtensionRec __DRI2flushExtension;
87 typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension;
88 typedef struct __DRI2fenceExtensionRec __DRI2fenceExtension;
89
90
91 typedef struct __DRIimageLoaderExtensionRec __DRIimageLoaderExtension;
92 typedef struct __DRIimageDriverExtensionRec __DRIimageDriverExtension;
93
94 /*@}*/
95
96
97 /**
98 * Extension struct. Drivers 'inherit' from this struct by embedding
99 * it as the first element in the extension struct.
100 *
101 * We never break API in for a DRI extension. If we need to change
102 * the way things work in a non-backwards compatible manner, we
103 * introduce a new extension. During a transition period, we can
104 * leave both the old and the new extension in the driver, which
105 * allows us to move to the new interface without having to update the
106 * loader(s) in lock step.
107 *
108 * However, we can add entry points to an extension over time as long
109 * as we don't break the old ones. As we add entry points to an
110 * extension, we increase the version number. The corresponding
111 * #define can be used to guard code that accesses the new entry
112 * points at compile time and the version field in the extension
113 * struct can be used at run-time to determine how to use the
114 * extension.
115 */
116 struct __DRIextensionRec {
117 const char *name;
118 int version;
119 };
120
121 /**
122 * The first set of extension are the screen extensions, returned by
123 * __DRIcore::getExtensions(). This entry point will return a list of
124 * extensions and the loader can use the ones it knows about by
125 * casting them to more specific extensions and advertising any GLX
126 * extensions the DRI extensions enables.
127 */
128
129 /**
130 * Used by drivers to indicate support for setting the read drawable.
131 */
132 #define __DRI_READ_DRAWABLE "DRI_ReadDrawable"
133 #define __DRI_READ_DRAWABLE_VERSION 1
134
135 /**
136 * Used by drivers that implement the GLX_MESA_copy_sub_buffer extension.
137 */
138 #define __DRI_COPY_SUB_BUFFER "DRI_CopySubBuffer"
139 #define __DRI_COPY_SUB_BUFFER_VERSION 1
140 struct __DRIcopySubBufferExtensionRec {
141 __DRIextension base;
142 void (*copySubBuffer)(__DRIdrawable *drawable, int x, int y, int w, int h);
143 };
144
145 /**
146 * Used by drivers that implement the GLX_SGI_swap_control or
147 * GLX_MESA_swap_control extension.
148 */
149 #define __DRI_SWAP_CONTROL "DRI_SwapControl"
150 #define __DRI_SWAP_CONTROL_VERSION 1
151 struct __DRIswapControlExtensionRec {
152 __DRIextension base;
153 void (*setSwapInterval)(__DRIdrawable *drawable, unsigned int inteval);
154 unsigned int (*getSwapInterval)(__DRIdrawable *drawable);
155 };
156
157 /**
158 * Used by drivers that implement the GLX_MESA_swap_frame_usage extension.
159 */
160 #define __DRI_FRAME_TRACKING "DRI_FrameTracking"
161 #define __DRI_FRAME_TRACKING_VERSION 1
162 struct __DRIframeTrackingExtensionRec {
163 __DRIextension base;
164
165 /**
166 * Enable or disable frame usage tracking.
167 *
168 * \since Internal API version 20030317.
169 */
170 int (*frameTracking)(__DRIdrawable *drawable, GLboolean enable);
171
172 /**
173 * Retrieve frame usage information.
174 *
175 * \since Internal API version 20030317.
176 */
177 int (*queryFrameTracking)(__DRIdrawable *drawable,
178 int64_t * sbc, int64_t * missedFrames,
179 float * lastMissedUsage, float * usage);
180 };
181
182
183 /**
184 * Used by drivers that implement the GLX_SGI_video_sync extension.
185 */
186 #define __DRI_MEDIA_STREAM_COUNTER "DRI_MediaStreamCounter"
187 #define __DRI_MEDIA_STREAM_COUNTER_VERSION 1
188 struct __DRImediaStreamCounterExtensionRec {
189 __DRIextension base;
190
191 /**
192 * Wait for the MSC to equal target_msc, or, if that has already passed,
193 * the next time (MSC % divisor) is equal to remainder. If divisor is
194 * zero, the function will return as soon as MSC is greater than or equal
195 * to target_msc.
196 */
197 int (*waitForMSC)(__DRIdrawable *drawable,
198 int64_t target_msc, int64_t divisor, int64_t remainder,
199 int64_t * msc, int64_t * sbc);
200
201 /**
202 * Get the number of vertical refreshes since some point in time before
203 * this function was first called (i.e., system start up).
204 */
205 int (*getDrawableMSC)(__DRIscreen *screen, __DRIdrawable *drawable,
206 int64_t *msc);
207 };
208
209
210 #define __DRI_TEX_OFFSET "DRI_TexOffset"
211 #define __DRI_TEX_OFFSET_VERSION 1
212 struct __DRItexOffsetExtensionRec {
213 __DRIextension base;
214
215 /**
216 * Method to override base texture image with a driver specific 'offset'.
217 * The depth passed in allows e.g. to ignore the alpha channel of texture
218 * images where the non-alpha components don't occupy a whole texel.
219 *
220 * For GLX_EXT_texture_from_pixmap with AIGLX.
221 */
222 void (*setTexOffset)(__DRIcontext *pDRICtx, GLint texname,
223 unsigned long long offset, GLint depth, GLuint pitch);
224 };
225
226
227 /* Valid values for format in the setTexBuffer2 function below. These
228 * values match the GLX tokens for compatibility reasons, but we
229 * define them here since the DRI interface can't depend on GLX. */
230 #define __DRI_TEXTURE_FORMAT_NONE 0x20D8
231 #define __DRI_TEXTURE_FORMAT_RGB 0x20D9
232 #define __DRI_TEXTURE_FORMAT_RGBA 0x20DA
233
234 #define __DRI_TEX_BUFFER "DRI_TexBuffer"
235 #define __DRI_TEX_BUFFER_VERSION 3
236 struct __DRItexBufferExtensionRec {
237 __DRIextension base;
238
239 /**
240 * Method to override base texture image with the contents of a
241 * __DRIdrawable.
242 *
243 * For GLX_EXT_texture_from_pixmap with AIGLX. Deprecated in favor of
244 * setTexBuffer2 in version 2 of this interface
245 */
246 void (*setTexBuffer)(__DRIcontext *pDRICtx,
247 GLint target,
248 __DRIdrawable *pDraw);
249
250 /**
251 * Method to override base texture image with the contents of a
252 * __DRIdrawable, including the required texture format attribute.
253 *
254 * For GLX_EXT_texture_from_pixmap with AIGLX.
255 *
256 * \since 2
257 */
258 void (*setTexBuffer2)(__DRIcontext *pDRICtx,
259 GLint target,
260 GLint format,
261 __DRIdrawable *pDraw);
262 /**
263 * Method to release texture buffer in case some special platform
264 * need this.
265 *
266 * For GLX_EXT_texture_from_pixmap with AIGLX.
267 *
268 * \since 3
269 */
270 void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
271 GLint target,
272 __DRIdrawable *pDraw);
273 };
274
275 /**
276 * Used by drivers that implement DRI2
277 */
278 #define __DRI2_FLUSH "DRI2_Flush"
279 #define __DRI2_FLUSH_VERSION 4
280
281 #define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
282 #define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */
283 #define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2)
284
285 enum __DRI2throttleReason {
286 __DRI2_THROTTLE_SWAPBUFFER,
287 __DRI2_THROTTLE_COPYSUBBUFFER,
288 __DRI2_THROTTLE_FLUSHFRONT
289 };
290
291 struct __DRI2flushExtensionRec {
292 __DRIextension base;
293 void (*flush)(__DRIdrawable *drawable);
294
295 /**
296 * Ask the driver to call getBuffers/getBuffersWithFormat before
297 * it starts rendering again.
298 *
299 * \param drawable the drawable to invalidate
300 *
301 * \since 3
302 */
303 void (*invalidate)(__DRIdrawable *drawable);
304
305 /**
306 * This function reduces the number of flushes in the driver by combining
307 * several operations into one call.
308 *
309 * It can:
310 * - throttle
311 * - flush a drawable
312 * - flush a context
313 *
314 * \param context the context
315 * \param drawable the drawable to flush
316 * \param flags a combination of _DRI2_FLUSH_xxx flags
317 * \param throttle_reason the reason for throttling, 0 = no throttling
318 *
319 * \since 4
320 */
321 void (*flush_with_flags)(__DRIcontext *ctx,
322 __DRIdrawable *drawable,
323 unsigned flags,
324 enum __DRI2throttleReason throttle_reason);
325 };
326
327
328 /**
329 * Extension that the driver uses to request
330 * throttle callbacks.
331 */
332
333 #define __DRI2_THROTTLE "DRI2_Throttle"
334 #define __DRI2_THROTTLE_VERSION 1
335
336 struct __DRI2throttleExtensionRec {
337 __DRIextension base;
338 void (*throttle)(__DRIcontext *ctx,
339 __DRIdrawable *drawable,
340 enum __DRI2throttleReason reason);
341 };
342
343
344 /**
345 * Extension for fences / synchronization objects.
346 */
347
348 #define __DRI2_FENCE "DRI2_Fence"
349 #define __DRI2_FENCE_VERSION 1
350
351 #define __DRI2_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffllu
352
353 #define __DRI2_FENCE_FLAG_FLUSH_COMMANDS (1 << 0)
354
355 struct __DRI2fenceExtensionRec {
356 __DRIextension base;
357
358 /**
359 * Create and insert a fence into the command stream of the context.
360 */
361 void *(*create_fence)(__DRIcontext *ctx);
362
363 /**
364 * Get a fence associated with the OpenCL event object.
365 * This can be NULL, meaning that OpenCL interoperability is not supported.
366 */
367 void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event);
368
369 /**
370 * Destroy a fence.
371 */
372 void (*destroy_fence)(__DRIscreen *screen, void *fence);
373
374 /**
375 * This function waits and doesn't return until the fence is signalled
376 * or the timeout expires. It returns true if the fence has been signaled.
377 *
378 * \param ctx the context where commands are flushed
379 * \param fence the fence
380 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags
381 * \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE
382 */
383 GLboolean (*client_wait_sync)(__DRIcontext *ctx, void *fence,
384 unsigned flags, uint64_t timeout);
385
386 /**
387 * This function enqueues a wait command into the command stream of
388 * the context and then returns. When the execution reaches the wait
389 * command, no further execution will be done in the context until
390 * the fence is signaled. This is a no-op if the device doesn't support
391 * parallel execution of contexts.
392 *
393 * \param ctx the context where the waiting is done
394 * \param fence the fence
395 * \param flags a combination of __DRI2_FENCE_FLAG_xxx flags that make
396 * sense with this function (right now there are none)
397 */
398 void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags);
399 };
400
401
402 /*@}*/
403
404 /**
405 * The following extensions describe loader features that the DRI
406 * driver can make use of. Some of these are mandatory, such as the
407 * getDrawableInfo extension for DRI and the DRI Loader extensions for
408 * DRI2, while others are optional, and if present allow the driver to
409 * expose certain features. The loader pass in a NULL terminated
410 * array of these extensions to the driver in the createNewScreen
411 * constructor.
412 */
413
414 typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
415 typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
416 typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
417 typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
418 typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
419
420
421 /**
422 * Callback to getDrawableInfo protocol
423 */
424 #define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
425 #define __DRI_GET_DRAWABLE_INFO_VERSION 1
426 struct __DRIgetDrawableInfoExtensionRec {
427 __DRIextension base;
428
429 /**
430 * This function is used to get information about the position, size, and
431 * clip rects of a drawable.
432 */
433 GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
434 unsigned int * index, unsigned int * stamp,
435 int * x, int * y, int * width, int * height,
436 int * numClipRects, drm_clip_rect_t ** pClipRects,
437 int * backX, int * backY,
438 int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
439 void *loaderPrivate);
440 };
441
442 /**
443 * Callback to get system time for media stream counter extensions.
444 */
445 #define __DRI_SYSTEM_TIME "DRI_SystemTime"
446 #define __DRI_SYSTEM_TIME_VERSION 1
447 struct __DRIsystemTimeExtensionRec {
448 __DRIextension base;
449
450 /**
451 * Get the 64-bit unadjusted system time (UST).
452 */
453 int (*getUST)(int64_t * ust);
454
455 /**
456 * Get the media stream counter (MSC) rate.
457 *
458 * Matching the definition in GLX_OML_sync_control, this function returns
459 * the rate of the "media stream counter". In practical terms, this is
460 * the frame refresh rate of the display.
461 */
462 GLboolean (*getMSCRate)(__DRIdrawable *draw,
463 int32_t * numerator, int32_t * denominator,
464 void *loaderPrivate);
465 };
466
467 /**
468 * Damage reporting
469 */
470 #define __DRI_DAMAGE "DRI_Damage"
471 #define __DRI_DAMAGE_VERSION 1
472 struct __DRIdamageExtensionRec {
473 __DRIextension base;
474
475 /**
476 * Reports areas of the given drawable which have been modified by the
477 * driver.
478 *
479 * \param drawable which the drawing was done to.
480 * \param rects rectangles affected, with the drawable origin as the
481 * origin.
482 * \param x X offset of the drawable within the screen (used in the
483 * front_buffer case)
484 * \param y Y offset of the drawable within the screen.
485 * \param front_buffer boolean flag for whether the drawing to the
486 * drawable was actually done directly to the front buffer (instead
487 * of backing storage, for example)
488 * \param loaderPrivate the data passed in at createNewDrawable time
489 */
490 void (*reportDamage)(__DRIdrawable *draw,
491 int x, int y,
492 drm_clip_rect_t *rects, int num_rects,
493 GLboolean front_buffer,
494 void *loaderPrivate);
495 };
496
497 #define __DRI_SWRAST_IMAGE_OP_DRAW 1
498 #define __DRI_SWRAST_IMAGE_OP_CLEAR 2
499 #define __DRI_SWRAST_IMAGE_OP_SWAP 3
500
501 /**
502 * SWRast Loader extension.
503 */
504 #define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
505 #define __DRI_SWRAST_LOADER_VERSION 2
506 struct __DRIswrastLoaderExtensionRec {
507 __DRIextension base;
508
509 /*
510 * Drawable position and size
511 */
512 void (*getDrawableInfo)(__DRIdrawable *drawable,
513 int *x, int *y, int *width, int *height,
514 void *loaderPrivate);
515
516 /**
517 * Put image to drawable
518 */
519 void (*putImage)(__DRIdrawable *drawable, int op,
520 int x, int y, int width, int height,
521 char *data, void *loaderPrivate);
522
523 /**
524 * Get image from readable
525 */
526 void (*getImage)(__DRIdrawable *readable,
527 int x, int y, int width, int height,
528 char *data, void *loaderPrivate);
529
530 /**
531 * Put image to drawable
532 *
533 * \since 2
534 */
535 void (*putImage2)(__DRIdrawable *drawable, int op,
536 int x, int y, int width, int height, int stride,
537 char *data, void *loaderPrivate);
538 };
539
540 /**
541 * Invalidate loader extension. The presence of this extension
542 * indicates to the DRI driver that the loader will call invalidate in
543 * the __DRI2_FLUSH extension, whenever the needs to query for new
544 * buffers. This means that the DRI driver can drop the polling in
545 * glViewport().
546 *
547 * The extension doesn't provide any functionality, it's only use to
548 * indicate to the driver that it can use the new semantics. A DRI
549 * driver can use this to switch between the different semantics or
550 * just refuse to initialize if this extension isn't present.
551 */
552 #define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
553 #define __DRI_USE_INVALIDATE_VERSION 1
554
555 typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
556 struct __DRIuseInvalidateExtensionRec {
557 __DRIextension base;
558 };
559
560 /**
561 * The remaining extensions describe driver extensions, immediately
562 * available interfaces provided by the driver. To start using the
563 * driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
564 * the extension you need in the array.
565 */
566 #define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
567
568 /**
569 * This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
570 * suffixed by "_drivername", allowing multiple drivers to be built into one
571 * library, and also giving the driver the chance to return a variable driver
572 * extensions struct depending on the driver name being loaded or any other
573 * system state.
574 *
575 * The function prototype is:
576 *
577 * const __DRIextension **__driDriverGetExtensions_drivername(void);
578 */
579 #define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
580
581 /**
582 * Tokens for __DRIconfig attribs. A number of attributes defined by
583 * GLX or EGL standards are not in the table, as they must be provided
584 * by the loader. For example, FBConfig ID or visual ID, drawable type.
585 */
586
587 #define __DRI_ATTRIB_BUFFER_SIZE 1
588 #define __DRI_ATTRIB_LEVEL 2
589 #define __DRI_ATTRIB_RED_SIZE 3
590 #define __DRI_ATTRIB_GREEN_SIZE 4
591 #define __DRI_ATTRIB_BLUE_SIZE 5
592 #define __DRI_ATTRIB_LUMINANCE_SIZE 6
593 #define __DRI_ATTRIB_ALPHA_SIZE 7
594 #define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
595 #define __DRI_ATTRIB_DEPTH_SIZE 9
596 #define __DRI_ATTRIB_STENCIL_SIZE 10
597 #define __DRI_ATTRIB_ACCUM_RED_SIZE 11
598 #define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
599 #define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
600 #define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
601 #define __DRI_ATTRIB_SAMPLE_BUFFERS 15
602 #define __DRI_ATTRIB_SAMPLES 16
603 #define __DRI_ATTRIB_RENDER_TYPE 17
604 #define __DRI_ATTRIB_CONFIG_CAVEAT 18
605 #define __DRI_ATTRIB_CONFORMANT 19
606 #define __DRI_ATTRIB_DOUBLE_BUFFER 20
607 #define __DRI_ATTRIB_STEREO 21
608 #define __DRI_ATTRIB_AUX_BUFFERS 22
609 #define __DRI_ATTRIB_TRANSPARENT_TYPE 23
610 #define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
611 #define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
612 #define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
613 #define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
614 #define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
615 #define __DRI_ATTRIB_FLOAT_MODE 29
616 #define __DRI_ATTRIB_RED_MASK 30
617 #define __DRI_ATTRIB_GREEN_MASK 31
618 #define __DRI_ATTRIB_BLUE_MASK 32
619 #define __DRI_ATTRIB_ALPHA_MASK 33
620 #define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
621 #define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
622 #define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
623 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
624 #define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
625 #define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
626 #define __DRI_ATTRIB_SWAP_METHOD 40
627 #define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
628 #define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
629 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
630 #define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
631 #define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
632 #define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
633 #define __DRI_ATTRIB_YINVERTED 47
634 #define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
635
636 /* __DRI_ATTRIB_RENDER_TYPE */
637 #define __DRI_ATTRIB_RGBA_BIT 0x01
638 #define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
639 #define __DRI_ATTRIB_LUMINANCE_BIT 0x04
640 #define __DRI_ATTRIB_FLOAT_BIT 0x08
641 #define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10
642
643 /* __DRI_ATTRIB_CONFIG_CAVEAT */
644 #define __DRI_ATTRIB_SLOW_BIT 0x01
645 #define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
646
647 /* __DRI_ATTRIB_TRANSPARENT_TYPE */
648 #define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
649 #define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
650
651 /* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
652 #define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
653 #define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
654 #define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
655
656 /**
657 * This extension defines the core DRI functionality.
658 */
659 #define __DRI_CORE "DRI_Core"
660 #define __DRI_CORE_VERSION 1
661
662 struct __DRIcoreExtensionRec {
663 __DRIextension base;
664
665 __DRIscreen *(*createNewScreen)(int screen, int fd,
666 unsigned int sarea_handle,
667 const __DRIextension **extensions,
668 const __DRIconfig ***driverConfigs,
669 void *loaderPrivate);
670
671 void (*destroyScreen)(__DRIscreen *screen);
672
673 const __DRIextension **(*getExtensions)(__DRIscreen *screen);
674
675 int (*getConfigAttrib)(const __DRIconfig *config,
676 unsigned int attrib,
677 unsigned int *value);
678
679 int (*indexConfigAttrib)(const __DRIconfig *config, int index,
680 unsigned int *attrib, unsigned int *value);
681
682 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
683 const __DRIconfig *config,
684 unsigned int drawable_id,
685 unsigned int head,
686 void *loaderPrivate);
687
688 void (*destroyDrawable)(__DRIdrawable *drawable);
689
690 void (*swapBuffers)(__DRIdrawable *drawable);
691
692 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
693 const __DRIconfig *config,
694 __DRIcontext *shared,
695 void *loaderPrivate);
696
697 int (*copyContext)(__DRIcontext *dest,
698 __DRIcontext *src,
699 unsigned long mask);
700
701 void (*destroyContext)(__DRIcontext *context);
702
703 int (*bindContext)(__DRIcontext *ctx,
704 __DRIdrawable *pdraw,
705 __DRIdrawable *pread);
706
707 int (*unbindContext)(__DRIcontext *ctx);
708 };
709
710 /**
711 * Stored version of some component (i.e., server-side DRI module, kernel-side
712 * DRM, etc.).
713 *
714 * \todo
715 * There are several data structures that explicitly store a major version,
716 * minor version, and patch level. These structures should be modified to
717 * have a \c __DRIversionRec instead.
718 */
719 struct __DRIversionRec {
720 int major; /**< Major version number. */
721 int minor; /**< Minor version number. */
722 int patch; /**< Patch-level. */
723 };
724
725 /**
726 * Framebuffer information record. Used by libGL to communicate information
727 * about the framebuffer to the driver's \c __driCreateNewScreen function.
728 *
729 * In XFree86, most of this information is derrived from data returned by
730 * calling \c XF86DRIGetDeviceInfo.
731 *
732 * \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
733 * __driUtilCreateNewScreen CallCreateNewScreen
734 *
735 * \bug This structure could be better named.
736 */
737 struct __DRIframebufferRec {
738 unsigned char *base; /**< Framebuffer base address in the CPU's
739 * address space. This value is calculated by
740 * calling \c drmMap on the framebuffer handle
741 * returned by \c XF86DRIGetDeviceInfo (or a
742 * similar function).
743 */
744 int size; /**< Framebuffer size, in bytes. */
745 int stride; /**< Number of bytes from one line to the next. */
746 int width; /**< Pixel width of the framebuffer. */
747 int height; /**< Pixel height of the framebuffer. */
748 int dev_priv_size; /**< Size of the driver's dev-priv structure. */
749 void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
750 };
751
752
753 /**
754 * This extension provides alternative screen, drawable and context
755 * constructors for legacy DRI functionality. This is used in
756 * conjunction with the core extension.
757 */
758 #define __DRI_LEGACY "DRI_Legacy"
759 #define __DRI_LEGACY_VERSION 1
760
761 struct __DRIlegacyExtensionRec {
762 __DRIextension base;
763
764 __DRIscreen *(*createNewScreen)(int screen,
765 const __DRIversion *ddx_version,
766 const __DRIversion *dri_version,
767 const __DRIversion *drm_version,
768 const __DRIframebuffer *frame_buffer,
769 void *pSAREA, int fd,
770 const __DRIextension **extensions,
771 const __DRIconfig ***driver_configs,
772 void *loaderPrivate);
773
774 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
775 const __DRIconfig *config,
776 drm_drawable_t hwDrawable,
777 int renderType, const int *attrs,
778 void *loaderPrivate);
779
780 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
781 const __DRIconfig *config,
782 int render_type,
783 __DRIcontext *shared,
784 drm_context_t hwContext,
785 void *loaderPrivate);
786 };
787
788 /**
789 * This extension provides alternative screen, drawable and context
790 * constructors for swrast DRI functionality. This is used in
791 * conjunction with the core extension.
792 */
793 #define __DRI_SWRAST "DRI_SWRast"
794 #define __DRI_SWRAST_VERSION 4
795
796 struct __DRIswrastExtensionRec {
797 __DRIextension base;
798
799 __DRIscreen *(*createNewScreen)(int screen,
800 const __DRIextension **extensions,
801 const __DRIconfig ***driver_configs,
802 void *loaderPrivate);
803
804 __DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
805 const __DRIconfig *config,
806 void *loaderPrivate);
807
808 /* Since version 2 */
809 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
810 int api,
811 const __DRIconfig *config,
812 __DRIcontext *shared,
813 void *data);
814
815 /**
816 * Create a context for a particular API with a set of attributes
817 *
818 * \since version 3
819 *
820 * \sa __DRIdri2ExtensionRec::createContextAttribs
821 */
822 __DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
823 int api,
824 const __DRIconfig *config,
825 __DRIcontext *shared,
826 unsigned num_attribs,
827 const uint32_t *attribs,
828 unsigned *error,
829 void *loaderPrivate);
830
831 /**
832 * createNewScreen() with the driver extensions passed in.
833 *
834 * \since version 4
835 */
836 __DRIscreen *(*createNewScreen2)(int screen,
837 const __DRIextension **loader_extensions,
838 const __DRIextension **driver_extensions,
839 const __DRIconfig ***driver_configs,
840 void *loaderPrivate);
841
842 };
843
844 /** Common DRI function definitions, shared among DRI2 and Image extensions
845 */
846
847 typedef __DRIscreen *
848 (*__DRIcreateNewScreen2Func)(int screen, int fd,
849 const __DRIextension **extensions,
850 const __DRIextension **driver_extensions,
851 const __DRIconfig ***driver_configs,
852 void *loaderPrivate);
853
854 typedef __DRIdrawable *
855 (*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
856 const __DRIconfig *config,
857 void *loaderPrivate);
858
859 typedef __DRIcontext *
860 (*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
861 int api,
862 const __DRIconfig *config,
863 __DRIcontext *shared,
864 unsigned num_attribs,
865 const uint32_t *attribs,
866 unsigned *error,
867 void *loaderPrivate);
868
869 typedef unsigned int
870 (*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
871
872 /**
873 * DRI2 Loader extension.
874 */
875 #define __DRI_BUFFER_FRONT_LEFT 0
876 #define __DRI_BUFFER_BACK_LEFT 1
877 #define __DRI_BUFFER_FRONT_RIGHT 2
878 #define __DRI_BUFFER_BACK_RIGHT 3
879 #define __DRI_BUFFER_DEPTH 4
880 #define __DRI_BUFFER_STENCIL 5
881 #define __DRI_BUFFER_ACCUM 6
882 #define __DRI_BUFFER_FAKE_FRONT_LEFT 7
883 #define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
884 #define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
885 #define __DRI_BUFFER_HIZ 10
886
887 /* Inofficial and for internal use. Increase when adding a new buffer token. */
888 #define __DRI_BUFFER_COUNT 11
889
890 struct __DRIbufferRec {
891 unsigned int attachment;
892 unsigned int name;
893 unsigned int pitch;
894 unsigned int cpp;
895 unsigned int flags;
896 };
897
898 #define __DRI_DRI2_LOADER "DRI_DRI2Loader"
899 #define __DRI_DRI2_LOADER_VERSION 3
900 struct __DRIdri2LoaderExtensionRec {
901 __DRIextension base;
902
903 __DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
904 int *width, int *height,
905 unsigned int *attachments, int count,
906 int *out_count, void *loaderPrivate);
907
908 /**
909 * Flush pending front-buffer rendering
910 *
911 * Any rendering that has been performed to the
912 * \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
913 * \c __DRI_BUFFER_FRONT_LEFT.
914 *
915 * \param driDrawable Drawable whose front-buffer is to be flushed
916 * \param loaderPrivate Loader's private data that was previously passed
917 * into __DRIdri2ExtensionRec::createNewDrawable
918 *
919 * \since 2
920 */
921 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
922
923
924 /**
925 * Get list of buffers from the server
926 *
927 * Gets a list of buffer for the specified set of attachments. Unlike
928 * \c ::getBuffers, this function takes a list of attachments paired with
929 * opaque \c unsigned \c int value describing the format of the buffer.
930 * It is the responsibility of the caller to know what the service that
931 * allocates the buffers will expect to receive for the format.
932 *
933 * \param driDrawable Drawable whose buffers are being queried.
934 * \param width Output where the width of the buffers is stored.
935 * \param height Output where the height of the buffers is stored.
936 * \param attachments List of pairs of attachment ID and opaque format
937 * requested for the drawable.
938 * \param count Number of attachment / format pairs stored in
939 * \c attachments.
940 * \param loaderPrivate Loader's private data that was previously passed
941 * into __DRIdri2ExtensionRec::createNewDrawable.
942 *
943 * \since 3
944 */
945 __DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
946 int *width, int *height,
947 unsigned int *attachments, int count,
948 int *out_count, void *loaderPrivate);
949 };
950
951 /**
952 * This extension provides alternative screen, drawable and context
953 * constructors for DRI2.
954 */
955 #define __DRI_DRI2 "DRI_DRI2"
956 #define __DRI_DRI2_VERSION 4
957
958 #define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
959 #define __DRI_API_GLES 1 /**< OpenGL ES 1.x */
960 #define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */
961 #define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
962 #define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */
963
964 #define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
965 #define __DRI_CTX_ATTRIB_MINOR_VERSION 1
966 #define __DRI_CTX_ATTRIB_FLAGS 2
967
968 /**
969 * \requires __DRI2_ROBUSTNESS.
970 */
971 #define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
972
973 #define __DRI_CTX_FLAG_DEBUG 0x00000001
974 #define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
975
976 /**
977 * \requires __DRI2_ROBUSTNESS.
978 */
979 #define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004
980
981 /**
982 * \name Context reset strategies.
983 */
984 /*@{*/
985 #define __DRI_CTX_RESET_NO_NOTIFICATION 0
986 #define __DRI_CTX_RESET_LOSE_CONTEXT 1
987 /*@}*/
988
989 /**
990 * \name Reasons that __DRIdri2Extension::createContextAttribs might fail
991 */
992 /*@{*/
993 /** Success! */
994 #define __DRI_CTX_ERROR_SUCCESS 0
995
996 /** Memory allocation failure */
997 #define __DRI_CTX_ERROR_NO_MEMORY 1
998
999 /** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
1000 #define __DRI_CTX_ERROR_BAD_API 2
1001
1002 /** Client requested an API version that the driver can't do. */
1003 #define __DRI_CTX_ERROR_BAD_VERSION 3
1004
1005 /** Client requested a flag or combination of flags the driver can't do. */
1006 #define __DRI_CTX_ERROR_BAD_FLAG 4
1007
1008 /** Client requested an attribute the driver doesn't understand. */
1009 #define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
1010
1011 /** Client requested a flag the driver doesn't understand. */
1012 #define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
1013 /*@}*/
1014
1015 struct __DRIdri2ExtensionRec {
1016 __DRIextension base;
1017
1018 __DRIscreen *(*createNewScreen)(int screen, int fd,
1019 const __DRIextension **extensions,
1020 const __DRIconfig ***driver_configs,
1021 void *loaderPrivate);
1022
1023 __DRIcreateNewDrawableFunc createNewDrawable;
1024 __DRIcontext *(*createNewContext)(__DRIscreen *screen,
1025 const __DRIconfig *config,
1026 __DRIcontext *shared,
1027 void *loaderPrivate);
1028
1029 /* Since version 2 */
1030 __DRIgetAPIMaskFunc getAPIMask;
1031
1032 __DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
1033 int api,
1034 const __DRIconfig *config,
1035 __DRIcontext *shared,
1036 void *data);
1037
1038 __DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
1039 unsigned int attachment,
1040 unsigned int format,
1041 int width,
1042 int height);
1043 void (*releaseBuffer)(__DRIscreen *screen,
1044 __DRIbuffer *buffer);
1045
1046 /**
1047 * Create a context for a particular API with a set of attributes
1048 *
1049 * \since version 3
1050 *
1051 * \sa __DRIswrastExtensionRec::createContextAttribs
1052 */
1053 __DRIcreateContextAttribsFunc createContextAttribs;
1054
1055 /**
1056 * createNewScreen with the driver's extension list passed in.
1057 *
1058 * \since version 4
1059 */
1060 __DRIcreateNewScreen2Func createNewScreen2;
1061 };
1062
1063
1064 /**
1065 * This extension provides functionality to enable various EGLImage
1066 * extensions.
1067 */
1068 #define __DRI_IMAGE "DRI_IMAGE"
1069 #define __DRI_IMAGE_VERSION 11
1070
1071 /**
1072 * These formats correspond to the similarly named MESA_FORMAT_*
1073 * tokens, except in the native endian of the CPU. For example, on
1074 * little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
1075 * MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
1076 *
1077 * __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
1078 * by the driver (YUV planar formats) but serve as a base image for
1079 * creating sub-images for the different planes within the image.
1080 *
1081 * R8, GR88 and NONE should not be used with createImageFormName or
1082 * createImage, and are returned by query from sub images created with
1083 * createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
1084 */
1085 #define __DRI_IMAGE_FORMAT_RGB565 0x1001
1086 #define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
1087 #define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
1088 #define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
1089 #define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
1090 #define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
1091 #define __DRI_IMAGE_FORMAT_GR88 0x1007
1092 #define __DRI_IMAGE_FORMAT_NONE 0x1008
1093 #define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
1094 #define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
1095 #define __DRI_IMAGE_FORMAT_SARGB8 0x100b
1096
1097 #define __DRI_IMAGE_USE_SHARE 0x0001
1098 #define __DRI_IMAGE_USE_SCANOUT 0x0002
1099 #define __DRI_IMAGE_USE_CURSOR 0x0004 /* Depricated */
1100 #define __DRI_IMAGE_USE_LINEAR 0x0008
1101
1102
1103 /**
1104 * Four CC formats that matches with WL_DRM_FORMAT_* from wayland_drm.h
1105 * and GBM_FORMAT_* from gbm.h, used with createImageFromNames.
1106 *
1107 * \since 5
1108 */
1109
1110 #define __DRI_IMAGE_FOURCC_RGB565 0x36314752
1111 #define __DRI_IMAGE_FOURCC_ARGB8888 0x34325241
1112 #define __DRI_IMAGE_FOURCC_XRGB8888 0x34325258
1113 #define __DRI_IMAGE_FOURCC_ABGR8888 0x34324241
1114 #define __DRI_IMAGE_FOURCC_XBGR8888 0x34324258
1115 #define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258
1116 #define __DRI_IMAGE_FOURCC_YUV410 0x39565559
1117 #define __DRI_IMAGE_FOURCC_YUV411 0x31315559
1118 #define __DRI_IMAGE_FOURCC_YUV420 0x32315559
1119 #define __DRI_IMAGE_FOURCC_YUV422 0x36315559
1120 #define __DRI_IMAGE_FOURCC_YUV444 0x34325559
1121 #define __DRI_IMAGE_FOURCC_NV12 0x3231564e
1122 #define __DRI_IMAGE_FOURCC_NV16 0x3631564e
1123 #define __DRI_IMAGE_FOURCC_YUYV 0x56595559
1124
1125
1126 /**
1127 * Queryable on images created by createImageFromNames.
1128 *
1129 * RGB and RGBA are may be usable directly as images but its still
1130 * recommended to call fromPlanar with plane == 0.
1131 *
1132 * Y_U_V, Y_UV and Y_XUXV all requires call to fromPlanar to create
1133 * usable sub-images, sampling from images return raw YUV data and
1134 * color conversion needs to be done in the shader.
1135 *
1136 * \since 5
1137 */
1138
1139 #define __DRI_IMAGE_COMPONENTS_RGB 0x3001
1140 #define __DRI_IMAGE_COMPONENTS_RGBA 0x3002
1141 #define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
1142 #define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
1143 #define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
1144
1145
1146 /**
1147 * queryImage attributes
1148 */
1149
1150 #define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
1151 #define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
1152 #define __DRI_IMAGE_ATTRIB_NAME 0x2002
1153 #define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
1154 #define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */
1155 #define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005
1156 #define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */
1157 #define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions
1158 * 7+. Each query will return a
1159 * new fd. */
1160 #define __DRI_IMAGE_ATTRIB_FOURCC 0x2008 /* available in versions 11 */
1161 #define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */
1162
1163 enum __DRIYUVColorSpace {
1164 __DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
1165 __DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
1166 __DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
1167 __DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
1168 };
1169
1170 enum __DRISampleRange {
1171 __DRI_YUV_RANGE_UNDEFINED = 0,
1172 __DRI_YUV_FULL_RANGE = 0x3282,
1173 __DRI_YUV_NARROW_RANGE = 0x3283
1174 };
1175
1176 enum __DRIChromaSiting {
1177 __DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
1178 __DRI_YUV_CHROMA_SITING_0 = 0x3284,
1179 __DRI_YUV_CHROMA_SITING_0_5 = 0x3285
1180 };
1181
1182 /**
1183 * \name Reasons that __DRIimageExtensionRec::createImageFromTexture might fail
1184 */
1185 /*@{*/
1186 /** Success! */
1187 #define __DRI_IMAGE_ERROR_SUCCESS 0
1188
1189 /** Memory allocation failure */
1190 #define __DRI_IMAGE_ERROR_BAD_ALLOC 1
1191
1192 /** Client requested an invalid attribute for a texture object */
1193 #define __DRI_IMAGE_ERROR_BAD_MATCH 2
1194
1195 /** Client requested an invalid texture object */
1196 #define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
1197 /*@}*/
1198
1199 /**
1200 * \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
1201 */
1202 /*@{*/
1203 #define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
1204 /*@}*/
1205
1206 /**
1207 * blitImage flags
1208 */
1209
1210 #define __BLIT_FLAG_FLUSH 0x0001
1211 #define __BLIT_FLAG_FINISH 0x0002
1212
1213 typedef struct __DRIimageRec __DRIimage;
1214 typedef struct __DRIimageExtensionRec __DRIimageExtension;
1215 struct __DRIimageExtensionRec {
1216 __DRIextension base;
1217
1218 __DRIimage *(*createImageFromName)(__DRIscreen *screen,
1219 int width, int height, int format,
1220 int name, int pitch,
1221 void *loaderPrivate);
1222
1223 __DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
1224 int renderbuffer,
1225 void *loaderPrivate);
1226
1227 void (*destroyImage)(__DRIimage *image);
1228
1229 __DRIimage *(*createImage)(__DRIscreen *screen,
1230 int width, int height, int format,
1231 unsigned int use,
1232 void *loaderPrivate);
1233
1234 GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
1235
1236 /**
1237 * The new __DRIimage will share the content with the old one, see dup(2).
1238 */
1239 __DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
1240
1241 /**
1242 * Validate that a __DRIimage can be used a certain way.
1243 *
1244 * \since 2
1245 */
1246 GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
1247
1248 /**
1249 * Unlike createImageFromName __DRI_IMAGE_FORMAT is not but instead
1250 * __DRI_IMAGE_FOURCC and strides are in bytes not pixels. Stride is
1251 * also per block and not per pixel (for non-RGB, see gallium blocks).
1252 *
1253 * \since 5
1254 */
1255 __DRIimage *(*createImageFromNames)(__DRIscreen *screen,
1256 int width, int height, int fourcc,
1257 int *names, int num_names,
1258 int *strides, int *offsets,
1259 void *loaderPrivate);
1260
1261 /**
1262 * Create an image out of a sub-region of a parent image. This
1263 * entry point lets us create individual __DRIimages for different
1264 * planes in a planar buffer (typically yuv), for example. While a
1265 * sub-image shares the underlying buffer object with the parent
1266 * image and other sibling sub-images, the life times of parent and
1267 * sub-images are not dependent. Destroying the parent or a
1268 * sub-image doesn't affect other images. The underlying buffer
1269 * object is free when no __DRIimage remains that references it.
1270 *
1271 * Sub-images may overlap, but rendering to overlapping sub-images
1272 * is undefined.
1273 *
1274 * \since 5
1275 */
1276 __DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
1277 void *loaderPrivate);
1278
1279 /**
1280 * Create image from texture.
1281 *
1282 * \since 6
1283 */
1284 __DRIimage *(*createImageFromTexture)(__DRIcontext *context,
1285 int target,
1286 unsigned texture,
1287 int depth,
1288 int level,
1289 unsigned *error,
1290 void *loaderPrivate);
1291 /**
1292 * Like createImageFromNames, but takes a prime fd instead.
1293 *
1294 * \since 7
1295 */
1296 __DRIimage *(*createImageFromFds)(__DRIscreen *screen,
1297 int width, int height, int fourcc,
1298 int *fds, int num_fds,
1299 int *strides, int *offsets,
1300 void *loaderPrivate);
1301
1302 /**
1303 * Like createImageFromFds, but takes additional attributes.
1304 *
1305 * For EGL_EXT_image_dma_buf_import.
1306 *
1307 * \since 8
1308 */
1309 __DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
1310 int width, int height, int fourcc,
1311 int *fds, int num_fds,
1312 int *strides, int *offsets,
1313 enum __DRIYUVColorSpace color_space,
1314 enum __DRISampleRange sample_range,
1315 enum __DRIChromaSiting horiz_siting,
1316 enum __DRIChromaSiting vert_siting,
1317 unsigned *error,
1318 void *loaderPrivate);
1319
1320 /**
1321 * Blit a part of a __DRIimage to another and flushes
1322 *
1323 * flush_flag:
1324 * 0: no flush
1325 * __BLIT_FLAG_FLUSH: flush after the blit operation
1326 * __BLIT_FLAG_FINISH: flush and wait the blit finished
1327 *
1328 * \since 9
1329 */
1330 void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
1331 int dstx0, int dsty0, int dstwidth, int dstheight,
1332 int srcx0, int srcy0, int srcwidth, int srcheight,
1333 int flush_flag);
1334
1335 /**
1336 * Query for general capabilities of the driver that concern
1337 * buffer sharing and image importing.
1338 *
1339 * \since 10
1340 */
1341 int (*getCapabilities)(__DRIscreen *screen);
1342 };
1343
1344
1345 /**
1346 * This extension must be implemented by the loader and passed to the
1347 * driver at screen creation time. The EGLImage entry points in the
1348 * various client APIs take opaque EGLImage handles and use this
1349 * extension to map them to a __DRIimage. At version 1, this
1350 * extensions allows mapping EGLImage pointers to __DRIimage pointers,
1351 * but future versions could support other EGLImage-like, opaque types
1352 * with new lookup functions.
1353 */
1354 #define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
1355 #define __DRI_IMAGE_LOOKUP_VERSION 1
1356
1357 typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
1358 struct __DRIimageLookupExtensionRec {
1359 __DRIextension base;
1360
1361 __DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
1362 void *loaderPrivate);
1363 };
1364
1365 /**
1366 * This extension allows for common DRI2 options
1367 */
1368 #define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
1369 #define __DRI2_CONFIG_QUERY_VERSION 1
1370
1371 typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
1372 struct __DRI2configQueryExtensionRec {
1373 __DRIextension base;
1374
1375 int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);
1376 int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
1377 int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
1378 };
1379
1380 /**
1381 * Robust context driver extension.
1382 *
1383 * Existence of this extension means the driver can accept the
1384 * \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
1385 * \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
1386 * \c __DRIdri2ExtensionRec::createContextAttribs.
1387 */
1388 #define __DRI2_ROBUSTNESS "DRI_Robustness"
1389 #define __DRI2_ROBUSTNESS_VERSION 1
1390
1391 typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
1392 struct __DRIrobustnessExtensionRec {
1393 __DRIextension base;
1394 };
1395
1396 /**
1397 * DRI config options extension.
1398 *
1399 * This extension provides the XML string containing driver options for use by
1400 * the loader in supporting the driconf application.
1401 */
1402 #define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
1403 #define __DRI_CONFIG_OPTIONS_VERSION 1
1404
1405 typedef struct __DRIconfigOptionsExtensionRec {
1406 __DRIextension base;
1407 const char *xml;
1408 } __DRIconfigOptionsExtension;
1409
1410 /**
1411 * This extension provides a driver vtable to a set of common driver helper
1412 * functions (driCoreExtension, driDRI2Extension) within the driver
1413 * implementation, as opposed to having to pass them through a global
1414 * variable.
1415 *
1416 * It is not intended to be public API to the actual loader, and the vtable
1417 * layout may change at any time.
1418 */
1419 #define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
1420 #define __DRI_DRIVER_VTABLE_VERSION 1
1421
1422 typedef struct __DRIDriverVtableExtensionRec {
1423 __DRIextension base;
1424 const struct __DriverAPIRec *vtable;
1425 } __DRIDriverVtableExtension;
1426
1427 /**
1428 * Query renderer driver extension
1429 *
1430 * This allows the window system layer (either EGL or GLX) to query aspects of
1431 * hardware and driver support without creating a context.
1432 */
1433 #define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
1434 #define __DRI2_RENDERER_QUERY_VERSION 1
1435
1436 #define __DRI2_RENDERER_VENDOR_ID 0x0000
1437 #define __DRI2_RENDERER_DEVICE_ID 0x0001
1438 #define __DRI2_RENDERER_VERSION 0x0002
1439 #define __DRI2_RENDERER_ACCELERATED 0x0003
1440 #define __DRI2_RENDERER_VIDEO_MEMORY 0x0004
1441 #define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005
1442 #define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006
1443 #define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007
1444 #define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008
1445 #define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009
1446 #define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a
1447
1448 typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
1449 struct __DRI2rendererQueryExtensionRec {
1450 __DRIextension base;
1451
1452 int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
1453 int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
1454 };
1455
1456 /**
1457 * Image Loader extension. Drivers use this to allocate color buffers
1458 */
1459
1460 enum __DRIimageBufferMask {
1461 __DRI_IMAGE_BUFFER_BACK = (1 << 0),
1462 __DRI_IMAGE_BUFFER_FRONT = (1 << 1)
1463 };
1464
1465 struct __DRIimageList {
1466 uint32_t image_mask;
1467 __DRIimage *back;
1468 __DRIimage *front;
1469 };
1470
1471 #define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
1472 #define __DRI_IMAGE_LOADER_VERSION 1
1473
1474 struct __DRIimageLoaderExtensionRec {
1475 __DRIextension base;
1476
1477 /**
1478 * Allocate color buffers.
1479 *
1480 * \param driDrawable
1481 * \param width Width of allocated buffers
1482 * \param height Height of allocated buffers
1483 * \param format one of __DRI_IMAGE_FORMAT_*
1484 * \param stamp Address of variable to be updated when
1485 * getBuffers must be called again
1486 * \param loaderPrivate The loaderPrivate for driDrawable
1487 * \param buffer_mask Set of buffers to allocate
1488 * \param buffers Returned buffers
1489 */
1490 int (*getBuffers)(__DRIdrawable *driDrawable,
1491 unsigned int format,
1492 uint32_t *stamp,
1493 void *loaderPrivate,
1494 uint32_t buffer_mask,
1495 struct __DRIimageList *buffers);
1496
1497 /**
1498 * Flush pending front-buffer rendering
1499 *
1500 * Any rendering that has been performed to the
1501 * fake front will be flushed to the front
1502 *
1503 * \param driDrawable Drawable whose front-buffer is to be flushed
1504 * \param loaderPrivate Loader's private data that was previously passed
1505 * into __DRIdri2ExtensionRec::createNewDrawable
1506 */
1507 void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
1508 };
1509
1510 /**
1511 * DRI extension.
1512 */
1513
1514 #define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"
1515 #define __DRI_IMAGE_DRIVER_VERSION 1
1516
1517 struct __DRIimageDriverExtensionRec {
1518 __DRIextension base;
1519
1520 /* Common DRI functions, shared with DRI2 */
1521 __DRIcreateNewScreen2Func createNewScreen2;
1522 __DRIcreateNewDrawableFunc createNewDrawable;
1523 __DRIcreateContextAttribsFunc createContextAttribs;
1524 __DRIgetAPIMaskFunc getAPIMask;
1525 };
1526
1527 #endif