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