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