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