Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
PojavLauncherTeam
GitHub Repository: PojavLauncherTeam/mesa
Path: blob/21.2-virgl/include/GL/internal/dri_interface.h
7100 views
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 <[email protected]>
36
* \author Ian Romanick <[email protected]>
37
* \author Kristian Høgsberg <[email protected]>
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
#include <GL/gl.h>
52
53
#include <stdint.h>
54
55
/**
56
* \name DRI interface structures
57
*
58
* The following structures define the interface between the GLX client
59
* side library and the DRI (direct rendering infrastructure).
60
*/
61
/*@{*/
62
typedef struct __DRIdisplayRec __DRIdisplay;
63
typedef struct __DRIscreenRec __DRIscreen;
64
typedef struct __DRIcontextRec __DRIcontext;
65
typedef struct __DRIdrawableRec __DRIdrawable;
66
typedef struct __DRIconfigRec __DRIconfig;
67
typedef struct __DRIframebufferRec __DRIframebuffer;
68
typedef struct __DRIversionRec __DRIversion;
69
70
typedef struct __DRIcoreExtensionRec __DRIcoreExtension;
71
typedef struct __DRIextensionRec __DRIextension;
72
typedef struct __DRIcopySubBufferExtensionRec __DRIcopySubBufferExtension;
73
typedef struct __DRIswapControlExtensionRec __DRIswapControlExtension;
74
typedef struct __DRIframeTrackingExtensionRec __DRIframeTrackingExtension;
75
typedef struct __DRImediaStreamCounterExtensionRec __DRImediaStreamCounterExtension;
76
typedef struct __DRItexOffsetExtensionRec __DRItexOffsetExtension;
77
typedef struct __DRItexBufferExtensionRec __DRItexBufferExtension;
78
typedef struct __DRIlegacyExtensionRec __DRIlegacyExtension;
79
typedef struct __DRIswrastExtensionRec __DRIswrastExtension;
80
typedef struct __DRIbufferRec __DRIbuffer;
81
typedef struct __DRIdri2ExtensionRec __DRIdri2Extension;
82
typedef struct __DRIdri2LoaderExtensionRec __DRIdri2LoaderExtension;
83
typedef struct __DRI2flushExtensionRec __DRI2flushExtension;
84
typedef struct __DRI2throttleExtensionRec __DRI2throttleExtension;
85
typedef struct __DRI2fenceExtensionRec __DRI2fenceExtension;
86
typedef struct __DRI2interopExtensionRec __DRI2interopExtension;
87
typedef struct __DRI2blobExtensionRec __DRI2blobExtension;
88
typedef struct __DRI2bufferDamageExtensionRec __DRI2bufferDamageExtension;
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 3
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
* \since 2
256
*/
257
void (*setTexBuffer2)(__DRIcontext *pDRICtx,
258
GLint target,
259
GLint format,
260
__DRIdrawable *pDraw);
261
/**
262
* Method to release texture buffer in case some special platform
263
* need this.
264
*
265
* For GLX_EXT_texture_from_pixmap with AIGLX.
266
*
267
* \since 3
268
*/
269
void (*releaseTexBuffer)(__DRIcontext *pDRICtx,
270
GLint target,
271
__DRIdrawable *pDraw);
272
};
273
274
/**
275
* Used by drivers that implement DRI2
276
*/
277
#define __DRI2_FLUSH "DRI2_Flush"
278
#define __DRI2_FLUSH_VERSION 4
279
280
#define __DRI2_FLUSH_DRAWABLE (1 << 0) /* the drawable should be flushed. */
281
#define __DRI2_FLUSH_CONTEXT (1 << 1) /* glFlush should be called */
282
#define __DRI2_FLUSH_INVALIDATE_ANCILLARY (1 << 2)
283
284
enum __DRI2throttleReason {
285
__DRI2_THROTTLE_SWAPBUFFER,
286
__DRI2_THROTTLE_COPYSUBBUFFER,
287
__DRI2_THROTTLE_FLUSHFRONT
288
};
289
290
struct __DRI2flushExtensionRec {
291
__DRIextension base;
292
void (*flush)(__DRIdrawable *drawable);
293
294
/**
295
* Ask the driver to call getBuffers/getBuffersWithFormat before
296
* it starts rendering again.
297
*
298
* \param drawable the drawable to invalidate
299
*
300
* \since 3
301
*/
302
void (*invalidate)(__DRIdrawable *drawable);
303
304
/**
305
* This function reduces the number of flushes in the driver by combining
306
* several operations into one call.
307
*
308
* It can:
309
* - throttle
310
* - flush a drawable
311
* - flush a context
312
*
313
* \param context the context
314
* \param drawable the drawable to flush
315
* \param flags a combination of _DRI2_FLUSH_xxx flags
316
* \param throttle_reason the reason for throttling, 0 = no throttling
317
*
318
* \since 4
319
*/
320
void (*flush_with_flags)(__DRIcontext *ctx,
321
__DRIdrawable *drawable,
322
unsigned flags,
323
enum __DRI2throttleReason throttle_reason);
324
};
325
326
327
/**
328
* Extension that the driver uses to request
329
* throttle callbacks.
330
*/
331
332
#define __DRI2_THROTTLE "DRI2_Throttle"
333
#define __DRI2_THROTTLE_VERSION 1
334
335
struct __DRI2throttleExtensionRec {
336
__DRIextension base;
337
void (*throttle)(__DRIcontext *ctx,
338
__DRIdrawable *drawable,
339
enum __DRI2throttleReason reason);
340
};
341
342
/**
343
* Extension for EGL_ANDROID_blob_cache
344
*/
345
346
#define __DRI2_BLOB "DRI2_Blob"
347
#define __DRI2_BLOB_VERSION 1
348
349
typedef void
350
(*__DRIblobCacheSet) (const void *key, signed long keySize,
351
const void *value, signed long valueSize);
352
353
typedef signed long
354
(*__DRIblobCacheGet) (const void *key, signed long keySize,
355
void *value, signed long valueSize);
356
357
struct __DRI2blobExtensionRec {
358
__DRIextension base;
359
360
/**
361
* Set cache functions for setting and getting cache entries.
362
*/
363
void (*set_cache_funcs) (__DRIscreen *screen,
364
__DRIblobCacheSet set, __DRIblobCacheGet get);
365
};
366
367
/**
368
* Extension for fences / synchronization objects.
369
*/
370
371
#define __DRI2_FENCE "DRI2_Fence"
372
#define __DRI2_FENCE_VERSION 2
373
374
#define __DRI2_FENCE_TIMEOUT_INFINITE 0xffffffffffffffffull
375
376
#define __DRI2_FENCE_FLAG_FLUSH_COMMANDS (1 << 0)
377
378
/**
379
* \name Capabilities that might be returned by __DRI2fenceExtensionRec::get_capabilities
380
*/
381
/*@{*/
382
#define __DRI_FENCE_CAP_NATIVE_FD 1
383
/*@}*/
384
385
struct __DRI2fenceExtensionRec {
386
__DRIextension base;
387
388
/**
389
* Create and insert a fence into the command stream of the context.
390
*/
391
void *(*create_fence)(__DRIcontext *ctx);
392
393
/**
394
* Get a fence associated with the OpenCL event object.
395
* This can be NULL, meaning that OpenCL interoperability is not supported.
396
*/
397
void *(*get_fence_from_cl_event)(__DRIscreen *screen, intptr_t cl_event);
398
399
/**
400
* Destroy a fence.
401
*/
402
void (*destroy_fence)(__DRIscreen *screen, void *fence);
403
404
/**
405
* This function waits and doesn't return until the fence is signalled
406
* or the timeout expires. It returns true if the fence has been signaled.
407
*
408
* \param ctx the context where commands are flushed
409
* \param fence the fence
410
* \param flags a combination of __DRI2_FENCE_FLAG_xxx flags
411
* \param timeout the timeout in ns or __DRI2_FENCE_TIMEOUT_INFINITE
412
*/
413
GLboolean (*client_wait_sync)(__DRIcontext *ctx, void *fence,
414
unsigned flags, uint64_t timeout);
415
416
/**
417
* This function enqueues a wait command into the command stream of
418
* the context and then returns. When the execution reaches the wait
419
* command, no further execution will be done in the context until
420
* the fence is signaled. This is a no-op if the device doesn't support
421
* parallel execution of contexts.
422
*
423
* \param ctx the context where the waiting is done
424
* \param fence the fence
425
* \param flags a combination of __DRI2_FENCE_FLAG_xxx flags that make
426
* sense with this function (right now there are none)
427
*/
428
void (*server_wait_sync)(__DRIcontext *ctx, void *fence, unsigned flags);
429
430
/**
431
* Query for general capabilities of the driver that concern fences.
432
* Returns a bitmask of __DRI_FENCE_CAP_x
433
*
434
* \since 2
435
*/
436
unsigned (*get_capabilities)(__DRIscreen *screen);
437
438
/**
439
* Create an fd (file descriptor) associated fence. If the fence fd
440
* is -1, this behaves similarly to create_fence() except that when
441
* rendering is flushed the driver creates a fence fd. Otherwise,
442
* the driver wraps an existing fence fd.
443
*
444
* This is used to implement the EGL_ANDROID_native_fence_sync extension.
445
*
446
* \since 2
447
*
448
* \param ctx the context associated with the fence
449
* \param fd the fence fd or -1
450
*/
451
void *(*create_fence_fd)(__DRIcontext *ctx, int fd);
452
453
/**
454
* For fences created with create_fence_fd(), after rendering is flushed,
455
* this retrieves the native fence fd. Caller takes ownership of the
456
* fd and will close() it when it is no longer needed.
457
*
458
* \since 2
459
*
460
* \param screen the screen associated with the fence
461
* \param fence the fence
462
*/
463
int (*get_fence_fd)(__DRIscreen *screen, void *fence);
464
};
465
466
467
/**
468
* Extension for API interop.
469
* See GL/mesa_glinterop.h.
470
*/
471
472
#define __DRI2_INTEROP "DRI2_Interop"
473
#define __DRI2_INTEROP_VERSION 1
474
475
struct mesa_glinterop_device_info;
476
struct mesa_glinterop_export_in;
477
struct mesa_glinterop_export_out;
478
479
struct __DRI2interopExtensionRec {
480
__DRIextension base;
481
482
/** Same as MesaGLInterop*QueryDeviceInfo. */
483
int (*query_device_info)(__DRIcontext *ctx,
484
struct mesa_glinterop_device_info *out);
485
486
/** Same as MesaGLInterop*ExportObject. */
487
int (*export_object)(__DRIcontext *ctx,
488
struct mesa_glinterop_export_in *in,
489
struct mesa_glinterop_export_out *out);
490
};
491
492
493
/**
494
* Extension for limiting window system back buffer rendering to user-defined
495
* scissor region.
496
*/
497
498
#define __DRI2_BUFFER_DAMAGE "DRI2_BufferDamage"
499
#define __DRI2_BUFFER_DAMAGE_VERSION 1
500
501
struct __DRI2bufferDamageExtensionRec {
502
__DRIextension base;
503
504
/**
505
* Provides an array of rectangles representing an overriding scissor region
506
* for rendering operations performed to the specified drawable. These
507
* rectangles do not replace client API scissor regions or draw
508
* co-ordinates, but instead inform the driver of the overall bounds of all
509
* operations which will be issued before the next flush.
510
*
511
* Any rendering operations writing pixels outside this region to the
512
* drawable will have an undefined effect on the entire drawable.
513
*
514
* This entrypoint may only be called after the drawable has either been
515
* newly created or flushed, and before any rendering operations which write
516
* pixels to the drawable. Calling this entrypoint at any other time will
517
* have an undefined effect on the entire drawable.
518
*
519
* Calling this entrypoint with @nrects 0 and @rects NULL will reset the
520
* region to the buffer's full size. This entrypoint may be called once to
521
* reset the region, followed by a second call with a populated region,
522
* before a rendering call is made.
523
*
524
* Used to implement EGL_KHR_partial_update.
525
*
526
* \param drawable affected drawable
527
* \param nrects number of rectangles provided
528
* \param rects the array of rectangles, lower-left origin
529
*/
530
void (*set_damage_region)(__DRIdrawable *drawable, unsigned int nrects,
531
int *rects);
532
};
533
534
/*@}*/
535
536
/**
537
* The following extensions describe loader features that the DRI
538
* driver can make use of. Some of these are mandatory, such as the
539
* getDrawableInfo extension for DRI and the DRI Loader extensions for
540
* DRI2, while others are optional, and if present allow the driver to
541
* expose certain features. The loader pass in a NULL terminated
542
* array of these extensions to the driver in the createNewScreen
543
* constructor.
544
*/
545
546
typedef struct __DRIgetDrawableInfoExtensionRec __DRIgetDrawableInfoExtension;
547
typedef struct __DRIsystemTimeExtensionRec __DRIsystemTimeExtension;
548
typedef struct __DRIdamageExtensionRec __DRIdamageExtension;
549
typedef struct __DRIloaderExtensionRec __DRIloaderExtension;
550
typedef struct __DRIswrastLoaderExtensionRec __DRIswrastLoaderExtension;
551
552
553
/**
554
* Callback to getDrawableInfo protocol
555
*/
556
#define __DRI_GET_DRAWABLE_INFO "DRI_GetDrawableInfo"
557
#define __DRI_GET_DRAWABLE_INFO_VERSION 1
558
struct __DRIgetDrawableInfoExtensionRec {
559
__DRIextension base;
560
561
/**
562
* This function is used to get information about the position, size, and
563
* clip rects of a drawable.
564
*/
565
GLboolean (* getDrawableInfo) ( __DRIdrawable *drawable,
566
unsigned int * index, unsigned int * stamp,
567
int * x, int * y, int * width, int * height,
568
int * numClipRects, drm_clip_rect_t ** pClipRects,
569
int * backX, int * backY,
570
int * numBackClipRects, drm_clip_rect_t ** pBackClipRects,
571
void *loaderPrivate);
572
};
573
574
/**
575
* Callback to get system time for media stream counter extensions.
576
*/
577
#define __DRI_SYSTEM_TIME "DRI_SystemTime"
578
#define __DRI_SYSTEM_TIME_VERSION 1
579
struct __DRIsystemTimeExtensionRec {
580
__DRIextension base;
581
582
/**
583
* Get the 64-bit unadjusted system time (UST).
584
*/
585
int (*getUST)(int64_t * ust);
586
587
/**
588
* Get the media stream counter (MSC) rate.
589
*
590
* Matching the definition in GLX_OML_sync_control, this function returns
591
* the rate of the "media stream counter". In practical terms, this is
592
* the frame refresh rate of the display.
593
*/
594
GLboolean (*getMSCRate)(__DRIdrawable *draw,
595
int32_t * numerator, int32_t * denominator,
596
void *loaderPrivate);
597
};
598
599
/**
600
* Damage reporting
601
*/
602
#define __DRI_DAMAGE "DRI_Damage"
603
#define __DRI_DAMAGE_VERSION 1
604
struct __DRIdamageExtensionRec {
605
__DRIextension base;
606
607
/**
608
* Reports areas of the given drawable which have been modified by the
609
* driver.
610
*
611
* \param drawable which the drawing was done to.
612
* \param rects rectangles affected, with the drawable origin as the
613
* origin.
614
* \param x X offset of the drawable within the screen (used in the
615
* front_buffer case)
616
* \param y Y offset of the drawable within the screen.
617
* \param front_buffer boolean flag for whether the drawing to the
618
* drawable was actually done directly to the front buffer (instead
619
* of backing storage, for example)
620
* \param loaderPrivate the data passed in at createNewDrawable time
621
*/
622
void (*reportDamage)(__DRIdrawable *draw,
623
int x, int y,
624
drm_clip_rect_t *rects, int num_rects,
625
GLboolean front_buffer,
626
void *loaderPrivate);
627
};
628
629
#define __DRI_SWRAST_IMAGE_OP_DRAW 1
630
#define __DRI_SWRAST_IMAGE_OP_CLEAR 2
631
#define __DRI_SWRAST_IMAGE_OP_SWAP 3
632
633
/**
634
* SWRast Loader extension.
635
*/
636
#define __DRI_SWRAST_LOADER "DRI_SWRastLoader"
637
#define __DRI_SWRAST_LOADER_VERSION 6
638
struct __DRIswrastLoaderExtensionRec {
639
__DRIextension base;
640
641
/*
642
* Drawable position and size
643
*/
644
void (*getDrawableInfo)(__DRIdrawable *drawable,
645
int *x, int *y, int *width, int *height,
646
void *loaderPrivate);
647
648
/**
649
* Put image to drawable
650
*/
651
void (*putImage)(__DRIdrawable *drawable, int op,
652
int x, int y, int width, int height,
653
char *data, void *loaderPrivate);
654
655
/**
656
* Get image from readable
657
*/
658
void (*getImage)(__DRIdrawable *readable,
659
int x, int y, int width, int height,
660
char *data, void *loaderPrivate);
661
662
/**
663
* Put image to drawable
664
*
665
* \since 2
666
*/
667
void (*putImage2)(__DRIdrawable *drawable, int op,
668
int x, int y, int width, int height, int stride,
669
char *data, void *loaderPrivate);
670
671
/**
672
* Put image to drawable
673
*
674
* \since 3
675
*/
676
void (*getImage2)(__DRIdrawable *readable,
677
int x, int y, int width, int height, int stride,
678
char *data, void *loaderPrivate);
679
680
/**
681
* Put shm image to drawable
682
*
683
* \since 4
684
*/
685
void (*putImageShm)(__DRIdrawable *drawable, int op,
686
int x, int y, int width, int height, int stride,
687
int shmid, char *shmaddr, unsigned offset,
688
void *loaderPrivate);
689
/**
690
* Get shm image from readable
691
*
692
* \since 4
693
*/
694
void (*getImageShm)(__DRIdrawable *readable,
695
int x, int y, int width, int height,
696
int shmid, void *loaderPrivate);
697
698
/**
699
* Put shm image to drawable (v2)
700
*
701
* The original version fixes srcx/y to 0, and expected
702
* the offset to be adjusted. This version allows src x,y
703
* to not be included in the offset. This is needed to
704
* avoid certain overflow checks in the X server, that
705
* result in lost rendering.
706
*
707
* \since 5
708
*/
709
void (*putImageShm2)(__DRIdrawable *drawable, int op,
710
int x, int y,
711
int width, int height, int stride,
712
int shmid, char *shmaddr, unsigned offset,
713
void *loaderPrivate);
714
715
/**
716
* get shm image to drawable (v2)
717
*
718
* There are some cases where GLX can't use SHM, but DRI
719
* still tries, we need to get a return type for when to
720
* fallback to the non-shm path.
721
*
722
* \since 6
723
*/
724
GLboolean (*getImageShm2)(__DRIdrawable *readable,
725
int x, int y, int width, int height,
726
int shmid, void *loaderPrivate);
727
};
728
729
/**
730
* Invalidate loader extension. The presence of this extension
731
* indicates to the DRI driver that the loader will call invalidate in
732
* the __DRI2_FLUSH extension, whenever the needs to query for new
733
* buffers. This means that the DRI driver can drop the polling in
734
* glViewport().
735
*
736
* The extension doesn't provide any functionality, it's only use to
737
* indicate to the driver that it can use the new semantics. A DRI
738
* driver can use this to switch between the different semantics or
739
* just refuse to initialize if this extension isn't present.
740
*/
741
#define __DRI_USE_INVALIDATE "DRI_UseInvalidate"
742
#define __DRI_USE_INVALIDATE_VERSION 1
743
744
typedef struct __DRIuseInvalidateExtensionRec __DRIuseInvalidateExtension;
745
struct __DRIuseInvalidateExtensionRec {
746
__DRIextension base;
747
};
748
749
/**
750
* The remaining extensions describe driver extensions, immediately
751
* available interfaces provided by the driver. To start using the
752
* driver, dlsym() for the __DRI_DRIVER_EXTENSIONS symbol and look for
753
* the extension you need in the array.
754
*/
755
#define __DRI_DRIVER_EXTENSIONS "__driDriverExtensions"
756
757
/**
758
* This symbol replaces the __DRI_DRIVER_EXTENSIONS symbol, and will be
759
* suffixed by "_drivername", allowing multiple drivers to be built into one
760
* library, and also giving the driver the chance to return a variable driver
761
* extensions struct depending on the driver name being loaded or any other
762
* system state.
763
*
764
* The function prototype is:
765
*
766
* const __DRIextension **__driDriverGetExtensions_drivername(void);
767
*/
768
#define __DRI_DRIVER_GET_EXTENSIONS "__driDriverGetExtensions"
769
770
/**
771
* Tokens for __DRIconfig attribs. A number of attributes defined by
772
* GLX or EGL standards are not in the table, as they must be provided
773
* by the loader. For example, FBConfig ID or visual ID, drawable type.
774
*/
775
776
#define __DRI_ATTRIB_BUFFER_SIZE 1
777
#define __DRI_ATTRIB_LEVEL 2
778
#define __DRI_ATTRIB_RED_SIZE 3
779
#define __DRI_ATTRIB_GREEN_SIZE 4
780
#define __DRI_ATTRIB_BLUE_SIZE 5
781
#define __DRI_ATTRIB_LUMINANCE_SIZE 6
782
#define __DRI_ATTRIB_ALPHA_SIZE 7
783
#define __DRI_ATTRIB_ALPHA_MASK_SIZE 8
784
#define __DRI_ATTRIB_DEPTH_SIZE 9
785
#define __DRI_ATTRIB_STENCIL_SIZE 10
786
#define __DRI_ATTRIB_ACCUM_RED_SIZE 11
787
#define __DRI_ATTRIB_ACCUM_GREEN_SIZE 12
788
#define __DRI_ATTRIB_ACCUM_BLUE_SIZE 13
789
#define __DRI_ATTRIB_ACCUM_ALPHA_SIZE 14
790
#define __DRI_ATTRIB_SAMPLE_BUFFERS 15
791
#define __DRI_ATTRIB_SAMPLES 16
792
#define __DRI_ATTRIB_RENDER_TYPE 17
793
#define __DRI_ATTRIB_CONFIG_CAVEAT 18
794
#define __DRI_ATTRIB_CONFORMANT 19
795
#define __DRI_ATTRIB_DOUBLE_BUFFER 20
796
#define __DRI_ATTRIB_STEREO 21
797
#define __DRI_ATTRIB_AUX_BUFFERS 22
798
#define __DRI_ATTRIB_TRANSPARENT_TYPE 23
799
#define __DRI_ATTRIB_TRANSPARENT_INDEX_VALUE 24
800
#define __DRI_ATTRIB_TRANSPARENT_RED_VALUE 25
801
#define __DRI_ATTRIB_TRANSPARENT_GREEN_VALUE 26
802
#define __DRI_ATTRIB_TRANSPARENT_BLUE_VALUE 27
803
#define __DRI_ATTRIB_TRANSPARENT_ALPHA_VALUE 28
804
#define __DRI_ATTRIB_FLOAT_MODE 29
805
#define __DRI_ATTRIB_RED_MASK 30
806
#define __DRI_ATTRIB_GREEN_MASK 31
807
#define __DRI_ATTRIB_BLUE_MASK 32
808
#define __DRI_ATTRIB_ALPHA_MASK 33
809
#define __DRI_ATTRIB_MAX_PBUFFER_WIDTH 34
810
#define __DRI_ATTRIB_MAX_PBUFFER_HEIGHT 35
811
#define __DRI_ATTRIB_MAX_PBUFFER_PIXELS 36
812
#define __DRI_ATTRIB_OPTIMAL_PBUFFER_WIDTH 37
813
#define __DRI_ATTRIB_OPTIMAL_PBUFFER_HEIGHT 38
814
#define __DRI_ATTRIB_VISUAL_SELECT_GROUP 39
815
#define __DRI_ATTRIB_SWAP_METHOD 40
816
#define __DRI_ATTRIB_MAX_SWAP_INTERVAL 41
817
#define __DRI_ATTRIB_MIN_SWAP_INTERVAL 42
818
#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGB 43
819
#define __DRI_ATTRIB_BIND_TO_TEXTURE_RGBA 44
820
#define __DRI_ATTRIB_BIND_TO_MIPMAP_TEXTURE 45
821
#define __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS 46
822
#define __DRI_ATTRIB_YINVERTED 47
823
#define __DRI_ATTRIB_FRAMEBUFFER_SRGB_CAPABLE 48
824
#define __DRI_ATTRIB_MUTABLE_RENDER_BUFFER 49 /* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR */
825
#define __DRI_ATTRIB_RED_SHIFT 50
826
#define __DRI_ATTRIB_GREEN_SHIFT 51
827
#define __DRI_ATTRIB_BLUE_SHIFT 52
828
#define __DRI_ATTRIB_ALPHA_SHIFT 53
829
#define __DRI_ATTRIB_MAX 54
830
831
/* __DRI_ATTRIB_RENDER_TYPE */
832
#define __DRI_ATTRIB_RGBA_BIT 0x01
833
#define __DRI_ATTRIB_COLOR_INDEX_BIT 0x02
834
#define __DRI_ATTRIB_LUMINANCE_BIT 0x04
835
#define __DRI_ATTRIB_FLOAT_BIT 0x08
836
#define __DRI_ATTRIB_UNSIGNED_FLOAT_BIT 0x10
837
838
/* __DRI_ATTRIB_CONFIG_CAVEAT */
839
#define __DRI_ATTRIB_SLOW_BIT 0x01
840
#define __DRI_ATTRIB_NON_CONFORMANT_CONFIG 0x02
841
842
/* __DRI_ATTRIB_TRANSPARENT_TYPE */
843
#define __DRI_ATTRIB_TRANSPARENT_RGB 0x00
844
#define __DRI_ATTRIB_TRANSPARENT_INDEX 0x01
845
846
/* __DRI_ATTRIB_BIND_TO_TEXTURE_TARGETS */
847
#define __DRI_ATTRIB_TEXTURE_1D_BIT 0x01
848
#define __DRI_ATTRIB_TEXTURE_2D_BIT 0x02
849
#define __DRI_ATTRIB_TEXTURE_RECTANGLE_BIT 0x04
850
851
/* __DRI_ATTRIB_SWAP_METHOD */
852
/* Note that with the exception of __DRI_ATTRIB_SWAP_NONE, we need to define
853
* the same tokens as GLX. This is because old and current X servers will
854
* transmit the driconf value grabbed from the AIGLX driver untranslated as
855
* the GLX fbconfig value. __DRI_ATTRIB_SWAP_NONE is only used by dri drivers
856
* to signal to the dri core that the driconfig is single-buffer.
857
*/
858
#define __DRI_ATTRIB_SWAP_NONE 0x0000
859
#define __DRI_ATTRIB_SWAP_EXCHANGE 0x8061
860
#define __DRI_ATTRIB_SWAP_COPY 0x8062
861
#define __DRI_ATTRIB_SWAP_UNDEFINED 0x8063
862
863
/**
864
* This extension defines the core DRI functionality.
865
*
866
* Version >= 2 indicates that getConfigAttrib with __DRI_ATTRIB_SWAP_METHOD
867
* returns a reliable value.
868
*/
869
#define __DRI_CORE "DRI_Core"
870
#define __DRI_CORE_VERSION 2
871
872
struct __DRIcoreExtensionRec {
873
__DRIextension base;
874
875
__DRIscreen *(*createNewScreen)(int screen, int fd,
876
unsigned int sarea_handle,
877
const __DRIextension **extensions,
878
const __DRIconfig ***driverConfigs,
879
void *loaderPrivate);
880
881
void (*destroyScreen)(__DRIscreen *screen);
882
883
const __DRIextension **(*getExtensions)(__DRIscreen *screen);
884
885
int (*getConfigAttrib)(const __DRIconfig *config,
886
unsigned int attrib,
887
unsigned int *value);
888
889
int (*indexConfigAttrib)(const __DRIconfig *config, int index,
890
unsigned int *attrib, unsigned int *value);
891
892
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
893
const __DRIconfig *config,
894
unsigned int drawable_id,
895
unsigned int head,
896
void *loaderPrivate);
897
898
void (*destroyDrawable)(__DRIdrawable *drawable);
899
900
void (*swapBuffers)(__DRIdrawable *drawable);
901
902
__DRIcontext *(*createNewContext)(__DRIscreen *screen,
903
const __DRIconfig *config,
904
__DRIcontext *shared,
905
void *loaderPrivate);
906
907
int (*copyContext)(__DRIcontext *dest,
908
__DRIcontext *src,
909
unsigned long mask);
910
911
void (*destroyContext)(__DRIcontext *context);
912
913
int (*bindContext)(__DRIcontext *ctx,
914
__DRIdrawable *pdraw,
915
__DRIdrawable *pread);
916
917
int (*unbindContext)(__DRIcontext *ctx);
918
};
919
920
/**
921
* Stored version of some component (i.e., server-side DRI module, kernel-side
922
* DRM, etc.).
923
*
924
* \todo
925
* There are several data structures that explicitly store a major version,
926
* minor version, and patch level. These structures should be modified to
927
* have a \c __DRIversionRec instead.
928
*/
929
struct __DRIversionRec {
930
int major; /**< Major version number. */
931
int minor; /**< Minor version number. */
932
int patch; /**< Patch-level. */
933
};
934
935
/**
936
* Framebuffer information record. Used by libGL to communicate information
937
* about the framebuffer to the driver's \c __driCreateNewScreen function.
938
*
939
* In XFree86, most of this information is derrived from data returned by
940
* calling \c XF86DRIGetDeviceInfo.
941
*
942
* \sa XF86DRIGetDeviceInfo __DRIdisplayRec::createNewScreen
943
* __driUtilCreateNewScreen CallCreateNewScreen
944
*
945
* \bug This structure could be better named.
946
*/
947
struct __DRIframebufferRec {
948
unsigned char *base; /**< Framebuffer base address in the CPU's
949
* address space. This value is calculated by
950
* calling \c drmMap on the framebuffer handle
951
* returned by \c XF86DRIGetDeviceInfo (or a
952
* similar function).
953
*/
954
int size; /**< Framebuffer size, in bytes. */
955
int stride; /**< Number of bytes from one line to the next. */
956
int width; /**< Pixel width of the framebuffer. */
957
int height; /**< Pixel height of the framebuffer. */
958
int dev_priv_size; /**< Size of the driver's dev-priv structure. */
959
void *dev_priv; /**< Pointer to the driver's dev-priv structure. */
960
};
961
962
963
/**
964
* This extension provides alternative screen, drawable and context
965
* constructors for legacy DRI functionality. This is used in
966
* conjunction with the core extension.
967
*/
968
#define __DRI_LEGACY "DRI_Legacy"
969
#define __DRI_LEGACY_VERSION 1
970
971
struct __DRIlegacyExtensionRec {
972
__DRIextension base;
973
974
__DRIscreen *(*createNewScreen)(int screen,
975
const __DRIversion *ddx_version,
976
const __DRIversion *dri_version,
977
const __DRIversion *drm_version,
978
const __DRIframebuffer *frame_buffer,
979
void *pSAREA, int fd,
980
const __DRIextension **extensions,
981
const __DRIconfig ***driver_configs,
982
void *loaderPrivate);
983
984
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
985
const __DRIconfig *config,
986
drm_drawable_t hwDrawable,
987
int renderType, const int *attrs,
988
void *loaderPrivate);
989
990
__DRIcontext *(*createNewContext)(__DRIscreen *screen,
991
const __DRIconfig *config,
992
int render_type,
993
__DRIcontext *shared,
994
drm_context_t hwContext,
995
void *loaderPrivate);
996
};
997
998
/**
999
* This extension provides alternative screen, drawable and context
1000
* constructors for swrast DRI functionality. This is used in
1001
* conjunction with the core extension.
1002
*/
1003
#define __DRI_SWRAST "DRI_SWRast"
1004
#define __DRI_SWRAST_VERSION 4
1005
1006
struct __DRIswrastExtensionRec {
1007
__DRIextension base;
1008
1009
__DRIscreen *(*createNewScreen)(int screen,
1010
const __DRIextension **extensions,
1011
const __DRIconfig ***driver_configs,
1012
void *loaderPrivate);
1013
1014
__DRIdrawable *(*createNewDrawable)(__DRIscreen *screen,
1015
const __DRIconfig *config,
1016
void *loaderPrivate);
1017
1018
/* Since version 2 */
1019
__DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
1020
int api,
1021
const __DRIconfig *config,
1022
__DRIcontext *shared,
1023
void *data);
1024
1025
/**
1026
* Create a context for a particular API with a set of attributes
1027
*
1028
* \since version 3
1029
*
1030
* \sa __DRIdri2ExtensionRec::createContextAttribs
1031
*/
1032
__DRIcontext *(*createContextAttribs)(__DRIscreen *screen,
1033
int api,
1034
const __DRIconfig *config,
1035
__DRIcontext *shared,
1036
unsigned num_attribs,
1037
const uint32_t *attribs,
1038
unsigned *error,
1039
void *loaderPrivate);
1040
1041
/**
1042
* createNewScreen() with the driver extensions passed in.
1043
*
1044
* \since version 4
1045
*/
1046
__DRIscreen *(*createNewScreen2)(int screen,
1047
const __DRIextension **loader_extensions,
1048
const __DRIextension **driver_extensions,
1049
const __DRIconfig ***driver_configs,
1050
void *loaderPrivate);
1051
1052
};
1053
1054
/** Common DRI function definitions, shared among DRI2 and Image extensions
1055
*/
1056
1057
typedef __DRIscreen *
1058
(*__DRIcreateNewScreen2Func)(int screen, int fd,
1059
const __DRIextension **extensions,
1060
const __DRIextension **driver_extensions,
1061
const __DRIconfig ***driver_configs,
1062
void *loaderPrivate);
1063
1064
typedef __DRIdrawable *
1065
(*__DRIcreateNewDrawableFunc)(__DRIscreen *screen,
1066
const __DRIconfig *config,
1067
void *loaderPrivate);
1068
1069
typedef __DRIcontext *
1070
(*__DRIcreateContextAttribsFunc)(__DRIscreen *screen,
1071
int api,
1072
const __DRIconfig *config,
1073
__DRIcontext *shared,
1074
unsigned num_attribs,
1075
const uint32_t *attribs,
1076
unsigned *error,
1077
void *loaderPrivate);
1078
1079
typedef unsigned int
1080
(*__DRIgetAPIMaskFunc)(__DRIscreen *screen);
1081
1082
/**
1083
* DRI2 Loader extension.
1084
*/
1085
#define __DRI_BUFFER_FRONT_LEFT 0
1086
#define __DRI_BUFFER_BACK_LEFT 1
1087
#define __DRI_BUFFER_FRONT_RIGHT 2
1088
#define __DRI_BUFFER_BACK_RIGHT 3
1089
#define __DRI_BUFFER_DEPTH 4
1090
#define __DRI_BUFFER_STENCIL 5
1091
#define __DRI_BUFFER_ACCUM 6
1092
#define __DRI_BUFFER_FAKE_FRONT_LEFT 7
1093
#define __DRI_BUFFER_FAKE_FRONT_RIGHT 8
1094
#define __DRI_BUFFER_DEPTH_STENCIL 9 /**< Only available with DRI2 1.1 */
1095
#define __DRI_BUFFER_HIZ 10
1096
1097
/* Inofficial and for internal use. Increase when adding a new buffer token. */
1098
#define __DRI_BUFFER_COUNT 11
1099
1100
struct __DRIbufferRec {
1101
unsigned int attachment;
1102
unsigned int name;
1103
unsigned int pitch;
1104
unsigned int cpp;
1105
unsigned int flags;
1106
};
1107
1108
#define __DRI_DRI2_LOADER "DRI_DRI2Loader"
1109
#define __DRI_DRI2_LOADER_VERSION 5
1110
1111
enum dri_loader_cap {
1112
/* Whether the loader handles RGBA channel ordering correctly. If not,
1113
* only BGRA ordering can be exposed.
1114
*/
1115
DRI_LOADER_CAP_RGBA_ORDERING,
1116
DRI_LOADER_CAP_FP16,
1117
};
1118
1119
struct __DRIdri2LoaderExtensionRec {
1120
__DRIextension base;
1121
1122
__DRIbuffer *(*getBuffers)(__DRIdrawable *driDrawable,
1123
int *width, int *height,
1124
unsigned int *attachments, int count,
1125
int *out_count, void *loaderPrivate);
1126
1127
/**
1128
* Flush pending front-buffer rendering
1129
*
1130
* Any rendering that has been performed to the
1131
* \c __DRI_BUFFER_FAKE_FRONT_LEFT will be flushed to the
1132
* \c __DRI_BUFFER_FRONT_LEFT.
1133
*
1134
* \param driDrawable Drawable whose front-buffer is to be flushed
1135
* \param loaderPrivate Loader's private data that was previously passed
1136
* into __DRIdri2ExtensionRec::createNewDrawable
1137
*
1138
* \since 2
1139
*/
1140
void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
1141
1142
1143
/**
1144
* Get list of buffers from the server
1145
*
1146
* Gets a list of buffer for the specified set of attachments. Unlike
1147
* \c ::getBuffers, this function takes a list of attachments paired with
1148
* opaque \c unsigned \c int value describing the format of the buffer.
1149
* It is the responsibility of the caller to know what the service that
1150
* allocates the buffers will expect to receive for the format.
1151
*
1152
* \param driDrawable Drawable whose buffers are being queried.
1153
* \param width Output where the width of the buffers is stored.
1154
* \param height Output where the height of the buffers is stored.
1155
* \param attachments List of pairs of attachment ID and opaque format
1156
* requested for the drawable.
1157
* \param count Number of attachment / format pairs stored in
1158
* \c attachments.
1159
* \param loaderPrivate Loader's private data that was previously passed
1160
* into __DRIdri2ExtensionRec::createNewDrawable.
1161
*
1162
* \since 3
1163
*/
1164
__DRIbuffer *(*getBuffersWithFormat)(__DRIdrawable *driDrawable,
1165
int *width, int *height,
1166
unsigned int *attachments, int count,
1167
int *out_count, void *loaderPrivate);
1168
1169
/**
1170
* Return a loader capability value. If the loader doesn't know the enum,
1171
* it will return 0.
1172
*
1173
* \param loaderPrivate The last parameter of createNewScreen or
1174
* createNewScreen2.
1175
* \param cap See the enum.
1176
*
1177
* \since 4
1178
*/
1179
unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
1180
1181
/**
1182
* Clean up any loader state associated with an image.
1183
*
1184
* \param loaderPrivate Loader's private data that was previously passed
1185
* into a __DRIimageExtensionRec::createImage function
1186
* \since 5
1187
*/
1188
void (*destroyLoaderImageState)(void *loaderPrivate);
1189
};
1190
1191
/**
1192
* This extension provides alternative screen, drawable and context
1193
* constructors for DRI2.
1194
*/
1195
#define __DRI_DRI2 "DRI_DRI2"
1196
#define __DRI_DRI2_VERSION 4
1197
1198
#define __DRI_API_OPENGL 0 /**< OpenGL compatibility profile */
1199
#define __DRI_API_GLES 1 /**< OpenGL ES 1.x */
1200
#define __DRI_API_GLES2 2 /**< OpenGL ES 2.x */
1201
#define __DRI_API_OPENGL_CORE 3 /**< OpenGL 3.2+ core profile */
1202
#define __DRI_API_GLES3 4 /**< OpenGL ES 3.x */
1203
1204
#define __DRI_CTX_ATTRIB_MAJOR_VERSION 0
1205
#define __DRI_CTX_ATTRIB_MINOR_VERSION 1
1206
#define __DRI_CTX_ATTRIB_FLAGS 2
1207
1208
/**
1209
* \requires __DRI2_ROBUSTNESS.
1210
*/
1211
#define __DRI_CTX_ATTRIB_RESET_STRATEGY 3
1212
1213
#define __DRI_CTX_FLAG_DEBUG 0x00000001
1214
#define __DRI_CTX_FLAG_FORWARD_COMPATIBLE 0x00000002
1215
1216
/**
1217
* \requires __DRI2_ROBUSTNESS.
1218
*/
1219
#define __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS 0x00000004
1220
1221
/**
1222
* \requires __DRI2_NO_ERROR.
1223
*
1224
*/
1225
#define __DRI_CTX_FLAG_NO_ERROR 0x00000008
1226
1227
/**
1228
* \name Context reset strategies.
1229
*/
1230
/*@{*/
1231
#define __DRI_CTX_RESET_NO_NOTIFICATION 0
1232
#define __DRI_CTX_RESET_LOSE_CONTEXT 1
1233
/*@}*/
1234
1235
#define __DRI_CTX_ATTRIB_PRIORITY 4
1236
1237
#define __DRI_CTX_PRIORITY_LOW 0
1238
#define __DRI_CTX_PRIORITY_MEDIUM 1
1239
#define __DRI_CTX_PRIORITY_HIGH 2
1240
1241
/**
1242
* \name Context release behaviors.
1243
*/
1244
/*@{*/
1245
#define __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR 5
1246
1247
#define __DRI_CTX_RELEASE_BEHAVIOR_NONE 0
1248
#define __DRI_CTX_RELEASE_BEHAVIOR_FLUSH 1
1249
/*@}*/
1250
1251
/**
1252
* \name Reasons that __DRIdri2Extension::createContextAttribs might fail
1253
*/
1254
/*@{*/
1255
/** Success! */
1256
#define __DRI_CTX_ERROR_SUCCESS 0
1257
1258
/** Memory allocation failure */
1259
#define __DRI_CTX_ERROR_NO_MEMORY 1
1260
1261
/** Client requested an API (e.g., OpenGL ES 2.0) that the driver can't do. */
1262
#define __DRI_CTX_ERROR_BAD_API 2
1263
1264
/** Client requested an API version that the driver can't do. */
1265
#define __DRI_CTX_ERROR_BAD_VERSION 3
1266
1267
/** Client requested a flag or combination of flags the driver can't do. */
1268
#define __DRI_CTX_ERROR_BAD_FLAG 4
1269
1270
/** Client requested an attribute the driver doesn't understand. */
1271
#define __DRI_CTX_ERROR_UNKNOWN_ATTRIBUTE 5
1272
1273
/** Client requested a flag the driver doesn't understand. */
1274
#define __DRI_CTX_ERROR_UNKNOWN_FLAG 6
1275
/*@}*/
1276
1277
struct __DRIdri2ExtensionRec {
1278
__DRIextension base;
1279
1280
__DRIscreen *(*createNewScreen)(int screen, int fd,
1281
const __DRIextension **extensions,
1282
const __DRIconfig ***driver_configs,
1283
void *loaderPrivate);
1284
1285
__DRIcreateNewDrawableFunc createNewDrawable;
1286
__DRIcontext *(*createNewContext)(__DRIscreen *screen,
1287
const __DRIconfig *config,
1288
__DRIcontext *shared,
1289
void *loaderPrivate);
1290
1291
/* Since version 2 */
1292
__DRIgetAPIMaskFunc getAPIMask;
1293
1294
__DRIcontext *(*createNewContextForAPI)(__DRIscreen *screen,
1295
int api,
1296
const __DRIconfig *config,
1297
__DRIcontext *shared,
1298
void *data);
1299
1300
__DRIbuffer *(*allocateBuffer)(__DRIscreen *screen,
1301
unsigned int attachment,
1302
unsigned int format,
1303
int width,
1304
int height);
1305
void (*releaseBuffer)(__DRIscreen *screen,
1306
__DRIbuffer *buffer);
1307
1308
/**
1309
* Create a context for a particular API with a set of attributes
1310
*
1311
* \since version 3
1312
*
1313
* \sa __DRIswrastExtensionRec::createContextAttribs
1314
*/
1315
__DRIcreateContextAttribsFunc createContextAttribs;
1316
1317
/**
1318
* createNewScreen with the driver's extension list passed in.
1319
*
1320
* \since version 4
1321
*/
1322
__DRIcreateNewScreen2Func createNewScreen2;
1323
};
1324
1325
1326
/**
1327
* This extension provides functionality to enable various EGLImage
1328
* extensions.
1329
*/
1330
#define __DRI_IMAGE "DRI_IMAGE"
1331
#define __DRI_IMAGE_VERSION 19
1332
1333
/**
1334
* These formats correspond to the similarly named MESA_FORMAT_*
1335
* tokens, except in the native endian of the CPU. For example, on
1336
* little endian __DRI_IMAGE_FORMAT_XRGB8888 corresponds to
1337
* MESA_FORMAT_XRGB8888, but MESA_FORMAT_XRGB8888_REV on big endian.
1338
*
1339
* __DRI_IMAGE_FORMAT_NONE is for images that aren't directly usable
1340
* by the driver (YUV planar formats) but serve as a base image for
1341
* creating sub-images for the different planes within the image.
1342
*
1343
* R8, GR88 and NONE should not be used with createImageFromName or
1344
* createImage, and are returned by query from sub images created with
1345
* createImageFromNames (NONE, see above) and fromPlane (R8 & GR88).
1346
*/
1347
#define __DRI_IMAGE_FORMAT_RGB565 0x1001
1348
#define __DRI_IMAGE_FORMAT_XRGB8888 0x1002
1349
#define __DRI_IMAGE_FORMAT_ARGB8888 0x1003
1350
#define __DRI_IMAGE_FORMAT_ABGR8888 0x1004
1351
#define __DRI_IMAGE_FORMAT_XBGR8888 0x1005
1352
#define __DRI_IMAGE_FORMAT_R8 0x1006 /* Since version 5 */
1353
#define __DRI_IMAGE_FORMAT_GR88 0x1007
1354
#define __DRI_IMAGE_FORMAT_NONE 0x1008
1355
#define __DRI_IMAGE_FORMAT_XRGB2101010 0x1009
1356
#define __DRI_IMAGE_FORMAT_ARGB2101010 0x100a
1357
#define __DRI_IMAGE_FORMAT_SARGB8 0x100b
1358
#define __DRI_IMAGE_FORMAT_ARGB1555 0x100c
1359
#define __DRI_IMAGE_FORMAT_R16 0x100d
1360
#define __DRI_IMAGE_FORMAT_GR1616 0x100e
1361
#define __DRI_IMAGE_FORMAT_YUYV 0x100f
1362
#define __DRI_IMAGE_FORMAT_XBGR2101010 0x1010
1363
#define __DRI_IMAGE_FORMAT_ABGR2101010 0x1011
1364
#define __DRI_IMAGE_FORMAT_SABGR8 0x1012
1365
#define __DRI_IMAGE_FORMAT_UYVY 0x1013
1366
#define __DRI_IMAGE_FORMAT_XBGR16161616F 0x1014
1367
#define __DRI_IMAGE_FORMAT_ABGR16161616F 0x1015
1368
#define __DRI_IMAGE_FORMAT_SXRGB8 0x1016
1369
#define __DRI_IMAGE_FORMAT_ABGR16161616 0x1017
1370
1371
#define __DRI_IMAGE_USE_SHARE 0x0001
1372
#define __DRI_IMAGE_USE_SCANOUT 0x0002
1373
#define __DRI_IMAGE_USE_CURSOR 0x0004 /* Deprecated */
1374
#define __DRI_IMAGE_USE_LINEAR 0x0008
1375
/* The buffer will only be read by an external process after SwapBuffers,
1376
* in contrary to gbm buffers, front buffers and fake front buffers, which
1377
* could be read after a flush."
1378
*/
1379
#define __DRI_IMAGE_USE_BACKBUFFER 0x0010
1380
#define __DRI_IMAGE_USE_PROTECTED 0x0020
1381
1382
1383
#define __DRI_IMAGE_TRANSFER_READ 0x1
1384
#define __DRI_IMAGE_TRANSFER_WRITE 0x2
1385
#define __DRI_IMAGE_TRANSFER_READ_WRITE \
1386
(__DRI_IMAGE_TRANSFER_READ | __DRI_IMAGE_TRANSFER_WRITE)
1387
1388
/**
1389
* Extra fourcc formats used internally to Mesa with createImageFromNames.
1390
* The externally-available fourccs are defined by drm_fourcc.h (DRM_FORMAT_*)
1391
* and WL_DRM_FORMAT_* from wayland_drm.h.
1392
*
1393
* \since 5
1394
*/
1395
1396
#define __DRI_IMAGE_FOURCC_SARGB8888 0x83324258
1397
#define __DRI_IMAGE_FOURCC_SABGR8888 0x84324258
1398
#define __DRI_IMAGE_FOURCC_SXRGB8888 0x85324258
1399
#define __DRI_IMAGE_FOURCC_RGBA16161616 0x38344152 /* fourcc_code('R', 'A', '4', '8' ) */
1400
1401
/**
1402
* Queryable on images created by createImageFromNames.
1403
*
1404
* RGB and RGBA might be usable directly as images, but it's still
1405
* recommended to call fromPlanar with plane == 0.
1406
*
1407
* Y_U_V, Y_UV,Y_XUXV and Y_UXVX all requires call to fromPlanar to create
1408
* usable sub-images, sampling from images return raw YUV data and
1409
* color conversion needs to be done in the shader.
1410
*
1411
* \since 5
1412
*/
1413
1414
#define __DRI_IMAGE_COMPONENTS_RGB 0x3001
1415
#define __DRI_IMAGE_COMPONENTS_RGBA 0x3002
1416
#define __DRI_IMAGE_COMPONENTS_Y_U_V 0x3003
1417
#define __DRI_IMAGE_COMPONENTS_Y_UV 0x3004
1418
#define __DRI_IMAGE_COMPONENTS_Y_XUXV 0x3005
1419
#define __DRI_IMAGE_COMPONENTS_Y_UXVX 0x3008
1420
#define __DRI_IMAGE_COMPONENTS_AYUV 0x3009
1421
#define __DRI_IMAGE_COMPONENTS_XYUV 0x300A
1422
#define __DRI_IMAGE_COMPONENTS_R 0x3006
1423
#define __DRI_IMAGE_COMPONENTS_RG 0x3007
1424
1425
1426
/**
1427
* queryImage attributes
1428
*/
1429
1430
#define __DRI_IMAGE_ATTRIB_STRIDE 0x2000
1431
#define __DRI_IMAGE_ATTRIB_HANDLE 0x2001
1432
#define __DRI_IMAGE_ATTRIB_NAME 0x2002
1433
#define __DRI_IMAGE_ATTRIB_FORMAT 0x2003 /* available in versions 3+ */
1434
#define __DRI_IMAGE_ATTRIB_WIDTH 0x2004 /* available in versions 4+ */
1435
#define __DRI_IMAGE_ATTRIB_HEIGHT 0x2005
1436
#define __DRI_IMAGE_ATTRIB_COMPONENTS 0x2006 /* available in versions 5+ */
1437
#define __DRI_IMAGE_ATTRIB_FD 0x2007 /* available in versions
1438
* 7+. Each query will return a
1439
* new fd. */
1440
#define __DRI_IMAGE_ATTRIB_FOURCC 0x2008 /* available in versions 11 */
1441
#define __DRI_IMAGE_ATTRIB_NUM_PLANES 0x2009 /* available in versions 11 */
1442
1443
#define __DRI_IMAGE_ATTRIB_OFFSET 0x200A /* available in versions 13 */
1444
#define __DRI_IMAGE_ATTRIB_MODIFIER_LOWER 0x200B /* available in versions 14 */
1445
#define __DRI_IMAGE_ATTRIB_MODIFIER_UPPER 0x200C /* available in versions 14 */
1446
1447
enum __DRIYUVColorSpace {
1448
__DRI_YUV_COLOR_SPACE_UNDEFINED = 0,
1449
__DRI_YUV_COLOR_SPACE_ITU_REC601 = 0x327F,
1450
__DRI_YUV_COLOR_SPACE_ITU_REC709 = 0x3280,
1451
__DRI_YUV_COLOR_SPACE_ITU_REC2020 = 0x3281
1452
};
1453
1454
enum __DRISampleRange {
1455
__DRI_YUV_RANGE_UNDEFINED = 0,
1456
__DRI_YUV_FULL_RANGE = 0x3282,
1457
__DRI_YUV_NARROW_RANGE = 0x3283
1458
};
1459
1460
enum __DRIChromaSiting {
1461
__DRI_YUV_CHROMA_SITING_UNDEFINED = 0,
1462
__DRI_YUV_CHROMA_SITING_0 = 0x3284,
1463
__DRI_YUV_CHROMA_SITING_0_5 = 0x3285
1464
};
1465
1466
/**
1467
* \name Reasons that __DRIimageExtensionRec::createImageFromTexture or
1468
* __DRIimageExtensionRec::createImageFromDmaBufs might fail
1469
*/
1470
/*@{*/
1471
/** Success! */
1472
#define __DRI_IMAGE_ERROR_SUCCESS 0
1473
1474
/** Memory allocation failure */
1475
#define __DRI_IMAGE_ERROR_BAD_ALLOC 1
1476
1477
/** Client requested an invalid attribute */
1478
#define __DRI_IMAGE_ERROR_BAD_MATCH 2
1479
1480
/** Client requested an invalid texture object */
1481
#define __DRI_IMAGE_ERROR_BAD_PARAMETER 3
1482
1483
/** Client requested an invalid pitch and/or offset */
1484
#define __DRI_IMAGE_ERROR_BAD_ACCESS 4
1485
/*@}*/
1486
1487
/**
1488
* \name Capabilities that might be returned by __DRIimageExtensionRec::getCapabilities
1489
*/
1490
/*@{*/
1491
#define __DRI_IMAGE_CAP_GLOBAL_NAMES 1
1492
/*@}*/
1493
1494
/**
1495
* blitImage flags
1496
*/
1497
1498
#define __BLIT_FLAG_FLUSH 0x0001
1499
#define __BLIT_FLAG_FINISH 0x0002
1500
1501
/**
1502
* Flags for createImageFromDmaBufs3
1503
*/
1504
#define __DRI_IMAGE_PROTECTED_CONTENT_FLAG 0x00000001
1505
1506
/**
1507
* queryDmaBufFormatModifierAttribs attributes
1508
*/
1509
1510
/* Available in version 16 */
1511
#define __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB_PLANE_COUNT 0x0001
1512
1513
typedef struct __DRIimageRec __DRIimage;
1514
typedef struct __DRIimageExtensionRec __DRIimageExtension;
1515
struct __DRIimageExtensionRec {
1516
__DRIextension base;
1517
1518
__DRIimage *(*createImageFromName)(__DRIscreen *screen,
1519
int width, int height, int format,
1520
int name, int pitch,
1521
void *loaderPrivate);
1522
1523
/* Deprecated since version 17; see createImageFromRenderbuffer2 */
1524
__DRIimage *(*createImageFromRenderbuffer)(__DRIcontext *context,
1525
int renderbuffer,
1526
void *loaderPrivate);
1527
1528
void (*destroyImage)(__DRIimage *image);
1529
1530
__DRIimage *(*createImage)(__DRIscreen *screen,
1531
int width, int height, int format,
1532
unsigned int use,
1533
void *loaderPrivate);
1534
1535
GLboolean (*queryImage)(__DRIimage *image, int attrib, int *value);
1536
1537
/**
1538
* The new __DRIimage will share the content with the old one, see dup(2).
1539
*/
1540
__DRIimage *(*dupImage)(__DRIimage *image, void *loaderPrivate);
1541
1542
/**
1543
* Validate that a __DRIimage can be used a certain way.
1544
*
1545
* \since 2
1546
*/
1547
GLboolean (*validateUsage)(__DRIimage *image, unsigned int use);
1548
1549
/**
1550
* Unlike createImageFromName __DRI_IMAGE_FORMAT is not used but instead
1551
* DRM_FORMAT_*, and strides are in bytes not pixels. Stride is
1552
* also per block and not per pixel (for non-RGB, see gallium blocks).
1553
*
1554
* \since 5
1555
*/
1556
__DRIimage *(*createImageFromNames)(__DRIscreen *screen,
1557
int width, int height, int fourcc,
1558
int *names, int num_names,
1559
int *strides, int *offsets,
1560
void *loaderPrivate);
1561
1562
/**
1563
* Create an image out of a sub-region of a parent image. This
1564
* entry point lets us create individual __DRIimages for different
1565
* planes in a planar buffer (typically yuv), for example. While a
1566
* sub-image shares the underlying buffer object with the parent
1567
* image and other sibling sub-images, the life times of parent and
1568
* sub-images are not dependent. Destroying the parent or a
1569
* sub-image doesn't affect other images. The underlying buffer
1570
* object is free when no __DRIimage remains that references it.
1571
*
1572
* Sub-images may overlap, but rendering to overlapping sub-images
1573
* is undefined.
1574
*
1575
* \since 5
1576
*/
1577
__DRIimage *(*fromPlanar)(__DRIimage *image, int plane,
1578
void *loaderPrivate);
1579
1580
/**
1581
* Create image from texture.
1582
*
1583
* \since 6
1584
*/
1585
__DRIimage *(*createImageFromTexture)(__DRIcontext *context,
1586
int target,
1587
unsigned texture,
1588
int depth,
1589
int level,
1590
unsigned *error,
1591
void *loaderPrivate);
1592
/**
1593
* Like createImageFromNames, but takes a prime fd instead.
1594
*
1595
* \since 7
1596
*/
1597
__DRIimage *(*createImageFromFds)(__DRIscreen *screen,
1598
int width, int height, int fourcc,
1599
int *fds, int num_fds,
1600
int *strides, int *offsets,
1601
void *loaderPrivate);
1602
1603
/**
1604
* Like createImageFromFds, but takes additional attributes.
1605
*
1606
* For EGL_EXT_image_dma_buf_import.
1607
*
1608
* \since 8
1609
*/
1610
__DRIimage *(*createImageFromDmaBufs)(__DRIscreen *screen,
1611
int width, int height, int fourcc,
1612
int *fds, int num_fds,
1613
int *strides, int *offsets,
1614
enum __DRIYUVColorSpace color_space,
1615
enum __DRISampleRange sample_range,
1616
enum __DRIChromaSiting horiz_siting,
1617
enum __DRIChromaSiting vert_siting,
1618
unsigned *error,
1619
void *loaderPrivate);
1620
1621
/**
1622
* Blit a part of a __DRIimage to another and flushes
1623
*
1624
* flush_flag:
1625
* 0: no flush
1626
* __BLIT_FLAG_FLUSH: flush after the blit operation
1627
* __BLIT_FLAG_FINISH: flush and wait the blit finished
1628
*
1629
* \since 9
1630
*/
1631
void (*blitImage)(__DRIcontext *context, __DRIimage *dst, __DRIimage *src,
1632
int dstx0, int dsty0, int dstwidth, int dstheight,
1633
int srcx0, int srcy0, int srcwidth, int srcheight,
1634
int flush_flag);
1635
1636
/**
1637
* Query for general capabilities of the driver that concern
1638
* buffer sharing and image importing.
1639
*
1640
* \since 10
1641
*/
1642
int (*getCapabilities)(__DRIscreen *screen);
1643
1644
/**
1645
* Returns a map of the specified region of a __DRIimage for the specified usage.
1646
*
1647
* flags may include __DRI_IMAGE_TRANSFER_READ, which will populate the
1648
* mapping with the current buffer content. If __DRI_IMAGE_TRANSFER_READ
1649
* is not included in the flags, the buffer content at map time is
1650
* undefined. Users wanting to modify the mapping must include
1651
* __DRI_IMAGE_TRANSFER_WRITE; if __DRI_IMAGE_TRANSFER_WRITE is not
1652
* included, behaviour when writing the mapping is undefined.
1653
*
1654
* Returns the byte stride in *stride, and an opaque pointer to data
1655
* tracking the mapping in **data, which must be passed to unmapImage().
1656
*
1657
* \since 12
1658
*/
1659
void *(*mapImage)(__DRIcontext *context, __DRIimage *image,
1660
int x0, int y0, int width, int height,
1661
unsigned int flags, int *stride, void **data);
1662
1663
/**
1664
* Unmap a previously mapped __DRIimage
1665
*
1666
* \since 12
1667
*/
1668
void (*unmapImage)(__DRIcontext *context, __DRIimage *image, void *data);
1669
1670
1671
/**
1672
* Creates an image with implementation's favorite modifiers.
1673
*
1674
* This acts like createImage except there is a list of modifiers passed in
1675
* which the implementation may selectively use to create the DRIimage. The
1676
* result should be the implementation selects one modifier (perhaps it would
1677
* hold on to a few and later pick).
1678
*
1679
* The created image should be destroyed with destroyImage().
1680
*
1681
* Returns the new DRIimage. The chosen modifier can be obtained later on
1682
* and passed back to things like the kernel's AddFB2 interface.
1683
*
1684
* \sa __DRIimageRec::createImage
1685
*
1686
* \since 14
1687
*/
1688
__DRIimage *(*createImageWithModifiers)(__DRIscreen *screen,
1689
int width, int height, int format,
1690
const uint64_t *modifiers,
1691
const unsigned int modifier_count,
1692
void *loaderPrivate);
1693
1694
/*
1695
* Like createImageFromDmaBufs, but takes also format modifiers.
1696
*
1697
* For EGL_EXT_image_dma_buf_import_modifiers.
1698
*
1699
* \since 15
1700
*/
1701
__DRIimage *(*createImageFromDmaBufs2)(__DRIscreen *screen,
1702
int width, int height, int fourcc,
1703
uint64_t modifier,
1704
int *fds, int num_fds,
1705
int *strides, int *offsets,
1706
enum __DRIYUVColorSpace color_space,
1707
enum __DRISampleRange sample_range,
1708
enum __DRIChromaSiting horiz_siting,
1709
enum __DRIChromaSiting vert_siting,
1710
unsigned *error,
1711
void *loaderPrivate);
1712
1713
/*
1714
* dmabuf format query to support EGL_EXT_image_dma_buf_import_modifiers.
1715
*
1716
* \param max Maximum number of formats that can be accomodated into
1717
* \param formats. If zero, no formats are returned -
1718
* instead, the driver returns the total number of
1719
* supported dmabuf formats in \param count.
1720
* \param formats Buffer to fill formats into.
1721
* \param count Count of formats returned, or, total number of
1722
* supported formats in case \param max is zero.
1723
*
1724
* Returns true on success.
1725
*
1726
* \since 15
1727
*/
1728
GLboolean (*queryDmaBufFormats)(__DRIscreen *screen, int max,
1729
int *formats, int *count);
1730
1731
/*
1732
* dmabuf format modifier query for a given format to support
1733
* EGL_EXT_image_dma_buf_import_modifiers.
1734
*
1735
* \param fourcc The format to query modifiers for. If this format
1736
* is not supported by the driver, return false.
1737
* \param max Maximum number of modifiers that can be accomodated in
1738
* \param modifiers. If zero, no modifiers are returned -
1739
* instead, the driver returns the total number of
1740
* modifiers for \param format in \param count.
1741
* \param modifiers Buffer to fill modifiers into.
1742
* \param count Count of the modifiers returned, or, total number of
1743
* supported modifiers for \param fourcc in case
1744
* \param max is zero.
1745
*
1746
* Returns true upon success.
1747
*
1748
* \since 15
1749
*/
1750
GLboolean (*queryDmaBufModifiers)(__DRIscreen *screen, int fourcc,
1751
int max, uint64_t *modifiers,
1752
unsigned int *external_only,
1753
int *count);
1754
1755
/**
1756
* dmabuf format modifier attribute query for a given format and modifier.
1757
*
1758
* \param fourcc The format to query. If this format is not supported by
1759
* the driver, return false.
1760
* \param modifier The modifier to query. If this format+modifier is not
1761
* supported by the driver, return false.
1762
* \param attrib The __DRI_IMAGE_FORMAT_MODIFIER_ATTRIB to query.
1763
* \param value A pointer to where to store the result of the query.
1764
*
1765
* Returns true upon success.
1766
*
1767
* \since 16
1768
*/
1769
GLboolean (*queryDmaBufFormatModifierAttribs)(__DRIscreen *screen,
1770
uint32_t fourcc, uint64_t modifier,
1771
int attrib, uint64_t *value);
1772
1773
/**
1774
* Create a DRI image from the given renderbuffer.
1775
*
1776
* \param context the current DRI context
1777
* \param renderbuffer the GL name of the renderbuffer
1778
* \param loaderPrivate for callbacks into the loader related to the image
1779
* \param error will be set to one of __DRI_IMAGE_ERROR_xxx
1780
* \return the newly created image on success, or NULL otherwise
1781
*
1782
* \since 17
1783
*/
1784
__DRIimage *(*createImageFromRenderbuffer2)(__DRIcontext *context,
1785
int renderbuffer,
1786
void *loaderPrivate,
1787
unsigned *error);
1788
1789
/*
1790
* Like createImageFromDmaBufs2, but with an added flags parameter.
1791
*
1792
* See __DRI_IMAGE_*_FLAG for valid definitions of flags.
1793
*
1794
* \since 18
1795
*/
1796
__DRIimage *(*createImageFromDmaBufs3)(__DRIscreen *screen,
1797
int width, int height, int fourcc,
1798
uint64_t modifier,
1799
int *fds, int num_fds,
1800
int *strides, int *offsets,
1801
enum __DRIYUVColorSpace color_space,
1802
enum __DRISampleRange sample_range,
1803
enum __DRIChromaSiting horiz_siting,
1804
enum __DRIChromaSiting vert_siting,
1805
uint32_t flags,
1806
unsigned *error,
1807
void *loaderPrivate);
1808
1809
/**
1810
* Creates an image with implementation's favorite modifiers and the
1811
* provided usage flags.
1812
*
1813
* This acts like createImageWithModifiers except usage is also specified.
1814
*
1815
* The created image should be destroyed with destroyImage().
1816
*
1817
* Returns the new DRIimage. The chosen modifier can be obtained later on
1818
* and passed back to things like the kernel's AddFB2 interface.
1819
*
1820
* \sa __DRIimageRec::createImage
1821
*
1822
* \since 19
1823
*/
1824
__DRIimage *(*createImageWithModifiers2)(__DRIscreen *screen,
1825
int width, int height, int format,
1826
const uint64_t *modifiers,
1827
const unsigned int modifier_count,
1828
unsigned int use,
1829
void *loaderPrivate);
1830
};
1831
1832
1833
/**
1834
* This extension must be implemented by the loader and passed to the
1835
* driver at screen creation time. The EGLImage entry points in the
1836
* various client APIs take opaque EGLImage handles and use this
1837
* extension to map them to a __DRIimage. At version 1, this
1838
* extensions allows mapping EGLImage pointers to __DRIimage pointers,
1839
* but future versions could support other EGLImage-like, opaque types
1840
* with new lookup functions.
1841
*/
1842
#define __DRI_IMAGE_LOOKUP "DRI_IMAGE_LOOKUP"
1843
#define __DRI_IMAGE_LOOKUP_VERSION 1
1844
1845
typedef struct __DRIimageLookupExtensionRec __DRIimageLookupExtension;
1846
struct __DRIimageLookupExtensionRec {
1847
__DRIextension base;
1848
1849
__DRIimage *(*lookupEGLImage)(__DRIscreen *screen, void *image,
1850
void *loaderPrivate);
1851
};
1852
1853
/**
1854
* This extension allows for common DRI2 options
1855
*/
1856
#define __DRI2_CONFIG_QUERY "DRI_CONFIG_QUERY"
1857
#define __DRI2_CONFIG_QUERY_VERSION 2
1858
1859
typedef struct __DRI2configQueryExtensionRec __DRI2configQueryExtension;
1860
struct __DRI2configQueryExtensionRec {
1861
__DRIextension base;
1862
1863
int (*configQueryb)(__DRIscreen *screen, const char *var, unsigned char *val);
1864
int (*configQueryi)(__DRIscreen *screen, const char *var, int *val);
1865
int (*configQueryf)(__DRIscreen *screen, const char *var, float *val);
1866
int (*configQuerys)(__DRIscreen *screen, const char *var, char **val);
1867
};
1868
1869
/**
1870
* Robust context driver extension.
1871
*
1872
* Existence of this extension means the driver can accept the
1873
* \c __DRI_CTX_FLAG_ROBUST_BUFFER_ACCESS flag and the
1874
* \c __DRI_CTX_ATTRIB_RESET_STRATEGY attribute in
1875
* \c __DRIdri2ExtensionRec::createContextAttribs.
1876
*/
1877
#define __DRI2_ROBUSTNESS "DRI_Robustness"
1878
#define __DRI2_ROBUSTNESS_VERSION 1
1879
1880
typedef struct __DRIrobustnessExtensionRec __DRIrobustnessExtension;
1881
struct __DRIrobustnessExtensionRec {
1882
__DRIextension base;
1883
};
1884
1885
/**
1886
* No-error context driver extension.
1887
*
1888
* Existence of this extension means the driver can accept the
1889
* __DRI_CTX_FLAG_NO_ERROR flag.
1890
*/
1891
#define __DRI2_NO_ERROR "DRI_NoError"
1892
#define __DRI2_NO_ERROR_VERSION 1
1893
1894
typedef struct __DRInoErrorExtensionRec {
1895
__DRIextension base;
1896
} __DRInoErrorExtension;
1897
1898
/*
1899
* Flush control driver extension.
1900
*
1901
* Existence of this extension means the driver can accept the
1902
* \c __DRI_CTX_ATTRIB_RELEASE_BEHAVIOR attribute in
1903
* \c __DRIdri2ExtensionRec::createContextAttribs.
1904
*/
1905
#define __DRI2_FLUSH_CONTROL "DRI_FlushControl"
1906
#define __DRI2_FLUSH_CONTROL_VERSION 1
1907
1908
typedef struct __DRI2flushControlExtensionRec __DRI2flushControlExtension;
1909
struct __DRI2flushControlExtensionRec {
1910
__DRIextension base;
1911
};
1912
1913
/**
1914
* DRI config options extension.
1915
*
1916
* This extension provides the XML string containing driver options for use by
1917
* the loader in supporting the driconf application.
1918
*
1919
* v2:
1920
* - Add the getXml getter function which allows the driver more flexibility in
1921
* how the XML is provided.
1922
* - Deprecate the direct xml pointer. It is only provided as a fallback for
1923
* older versions of libGL and must not be used by clients that are aware of
1924
* the newer version. Future driver versions may set it to NULL.
1925
*/
1926
#define __DRI_CONFIG_OPTIONS "DRI_ConfigOptions"
1927
#define __DRI_CONFIG_OPTIONS_VERSION 2
1928
1929
typedef struct __DRIconfigOptionsExtensionRec {
1930
__DRIextension base;
1931
const char *xml; /**< deprecated since v2, use getXml instead */
1932
1933
/**
1934
* Get an XML string that describes available driver options for use by a
1935
* config application.
1936
*
1937
* The returned string must be heap-allocated. The caller is responsible for
1938
* freeing it.
1939
*/
1940
char *(*getXml)(const char *driver_name);
1941
} __DRIconfigOptionsExtension;
1942
1943
/**
1944
* This extension provides a driver vtable to a set of common driver helper
1945
* functions (driCoreExtension, driDRI2Extension) within the driver
1946
* implementation, as opposed to having to pass them through a global
1947
* variable.
1948
*
1949
* It is not intended to be public API to the actual loader, and the vtable
1950
* layout may change at any time.
1951
*/
1952
#define __DRI_DRIVER_VTABLE "DRI_DriverVtable"
1953
#define __DRI_DRIVER_VTABLE_VERSION 1
1954
1955
typedef struct __DRIDriverVtableExtensionRec {
1956
__DRIextension base;
1957
const struct __DriverAPIRec *vtable;
1958
} __DRIDriverVtableExtension;
1959
1960
/**
1961
* Query renderer driver extension
1962
*
1963
* This allows the window system layer (either EGL or GLX) to query aspects of
1964
* hardware and driver support without creating a context.
1965
*/
1966
#define __DRI2_RENDERER_QUERY "DRI_RENDERER_QUERY"
1967
#define __DRI2_RENDERER_QUERY_VERSION 1
1968
1969
#define __DRI2_RENDERER_VENDOR_ID 0x0000
1970
#define __DRI2_RENDERER_DEVICE_ID 0x0001
1971
#define __DRI2_RENDERER_VERSION 0x0002
1972
#define __DRI2_RENDERER_ACCELERATED 0x0003
1973
#define __DRI2_RENDERER_VIDEO_MEMORY 0x0004
1974
#define __DRI2_RENDERER_UNIFIED_MEMORY_ARCHITECTURE 0x0005
1975
#define __DRI2_RENDERER_PREFERRED_PROFILE 0x0006
1976
#define __DRI2_RENDERER_OPENGL_CORE_PROFILE_VERSION 0x0007
1977
#define __DRI2_RENDERER_OPENGL_COMPATIBILITY_PROFILE_VERSION 0x0008
1978
#define __DRI2_RENDERER_OPENGL_ES_PROFILE_VERSION 0x0009
1979
#define __DRI2_RENDERER_OPENGL_ES2_PROFILE_VERSION 0x000a
1980
#define __DRI2_RENDERER_HAS_TEXTURE_3D 0x000b
1981
/* Whether there is an sRGB format support for every supported 32-bit UNORM
1982
* color format.
1983
*/
1984
#define __DRI2_RENDERER_HAS_FRAMEBUFFER_SRGB 0x000c
1985
1986
/* Bitmaks of supported/available context priorities - must match
1987
* __EGL_CONTEXT_PRIORITY_LOW_BIT et al
1988
*/
1989
#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY 0x000d
1990
#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_LOW (1 << 0)
1991
#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_MEDIUM (1 << 1)
1992
#define __DRI2_RENDERER_HAS_CONTEXT_PRIORITY_HIGH (1 << 2)
1993
1994
#define __DRI2_RENDERER_HAS_PROTECTED_CONTENT 0x000e
1995
1996
typedef struct __DRI2rendererQueryExtensionRec __DRI2rendererQueryExtension;
1997
struct __DRI2rendererQueryExtensionRec {
1998
__DRIextension base;
1999
2000
int (*queryInteger)(__DRIscreen *screen, int attribute, unsigned int *val);
2001
int (*queryString)(__DRIscreen *screen, int attribute, const char **val);
2002
};
2003
2004
/**
2005
* Image Loader extension. Drivers use this to allocate color buffers
2006
*/
2007
2008
/**
2009
* See __DRIimageLoaderExtensionRec::getBuffers::buffer_mask.
2010
*/
2011
enum __DRIimageBufferMask {
2012
__DRI_IMAGE_BUFFER_BACK = (1 << 0),
2013
__DRI_IMAGE_BUFFER_FRONT = (1 << 1),
2014
2015
/**
2016
* A buffer shared between application and compositor. The buffer may be
2017
* simultaneously accessed by each.
2018
*
2019
* A shared buffer is equivalent to an EGLSurface whose EGLConfig contains
2020
* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR and whose active EGL_RENDER_BUFFER (as
2021
* opposed to any pending, requested change to EGL_RENDER_BUFFER) is
2022
* EGL_SINGLE_BUFFER.
2023
*
2024
* If buffer_mask contains __DRI_IMAGE_BUFFER_SHARED, then must contains no
2025
* other bits. As a corollary, a __DRIdrawable that has a "shared" buffer
2026
* has no front nor back buffer.
2027
*
2028
* The loader returns __DRI_IMAGE_BUFFER_SHARED in buffer_mask if and only
2029
* if:
2030
* - The loader supports __DRI_MUTABLE_RENDER_BUFFER_LOADER.
2031
* - The driver supports __DRI_MUTABLE_RENDER_BUFFER_DRIVER.
2032
* - The EGLConfig of the drawable EGLSurface contains
2033
* EGL_MUTABLE_RENDER_BUFFER_BIT_KHR.
2034
* - The EGLContext's EGL_RENDER_BUFFER is EGL_SINGLE_BUFFER.
2035
* Equivalently, the EGLSurface's active EGL_RENDER_BUFFER (as
2036
* opposed to any pending, requested change to EGL_RENDER_BUFFER) is
2037
* EGL_SINGLE_BUFFER. (See the EGL 1.5 and
2038
* EGL_KHR_mutable_render_buffer spec for details about "pending" vs
2039
* "active" EGL_RENDER_BUFFER state).
2040
*
2041
* A shared buffer is similar to a front buffer in that all rendering to the
2042
* buffer should appear promptly on the screen. It is different from
2043
* a front buffer in that its behavior is independent from the
2044
* GL_DRAW_BUFFER state. Specifically, if GL_DRAW_FRAMEBUFFER is 0 and the
2045
* __DRIdrawable's buffer_mask is __DRI_IMAGE_BUFFER_SHARED, then all
2046
* rendering should appear promptly on the screen if GL_DRAW_BUFFER is not
2047
* GL_NONE.
2048
*
2049
* The difference between a shared buffer and a front buffer is motivated
2050
* by the constraints of Android and OpenGL ES. OpenGL ES does not support
2051
* front-buffer rendering. Android's SurfaceFlinger protocol provides the
2052
* EGL driver only a back buffer and no front buffer. The shared buffer
2053
* mode introduced by EGL_KHR_mutable_render_buffer is a backdoor though
2054
* EGL that allows Android OpenGL ES applications to render to what is
2055
* effectively the front buffer, a backdoor that required no change to the
2056
* OpenGL ES API and little change to the SurfaceFlinger API.
2057
*/
2058
__DRI_IMAGE_BUFFER_SHARED = (1 << 2),
2059
};
2060
2061
struct __DRIimageList {
2062
uint32_t image_mask;
2063
__DRIimage *back;
2064
__DRIimage *front;
2065
};
2066
2067
#define __DRI_IMAGE_LOADER "DRI_IMAGE_LOADER"
2068
#define __DRI_IMAGE_LOADER_VERSION 4
2069
2070
struct __DRIimageLoaderExtensionRec {
2071
__DRIextension base;
2072
2073
/**
2074
* Allocate color buffers.
2075
*
2076
* \param driDrawable
2077
* \param width Width of allocated buffers
2078
* \param height Height of allocated buffers
2079
* \param format one of __DRI_IMAGE_FORMAT_*
2080
* \param stamp Address of variable to be updated when
2081
* getBuffers must be called again
2082
* \param loaderPrivate The loaderPrivate for driDrawable
2083
* \param buffer_mask Set of buffers to allocate. A bitmask of
2084
* __DRIimageBufferMask.
2085
* \param buffers Returned buffers
2086
*/
2087
int (*getBuffers)(__DRIdrawable *driDrawable,
2088
unsigned int format,
2089
uint32_t *stamp,
2090
void *loaderPrivate,
2091
uint32_t buffer_mask,
2092
struct __DRIimageList *buffers);
2093
2094
/**
2095
* Flush pending front-buffer rendering
2096
*
2097
* Any rendering that has been performed to the
2098
* fake front will be flushed to the front
2099
*
2100
* \param driDrawable Drawable whose front-buffer is to be flushed
2101
* \param loaderPrivate Loader's private data that was previously passed
2102
* into __DRIdri2ExtensionRec::createNewDrawable
2103
*/
2104
void (*flushFrontBuffer)(__DRIdrawable *driDrawable, void *loaderPrivate);
2105
2106
/**
2107
* Return a loader capability value. If the loader doesn't know the enum,
2108
* it will return 0.
2109
*
2110
* \since 2
2111
*/
2112
unsigned (*getCapability)(void *loaderPrivate, enum dri_loader_cap cap);
2113
2114
/**
2115
* Flush swap buffers
2116
*
2117
* Make sure any outstanding swap buffers have been submitted to the
2118
* device.
2119
*
2120
* \param driDrawable Drawable whose swaps need to be flushed
2121
* \param loaderPrivate Loader's private data that was previously passed
2122
* into __DRIdri2ExtensionRec::createNewDrawable
2123
*
2124
* \since 3
2125
*/
2126
void (*flushSwapBuffers)(__DRIdrawable *driDrawable, void *loaderPrivate);
2127
2128
/**
2129
* Clean up any loader state associated with an image.
2130
*
2131
* \param loaderPrivate Loader's private data that was previously passed
2132
* into a __DRIimageExtensionRec::createImage function
2133
* \since 4
2134
*/
2135
void (*destroyLoaderImageState)(void *loaderPrivate);
2136
};
2137
2138
/**
2139
* DRI extension.
2140
*/
2141
2142
#define __DRI_IMAGE_DRIVER "DRI_IMAGE_DRIVER"
2143
#define __DRI_IMAGE_DRIVER_VERSION 1
2144
2145
struct __DRIimageDriverExtensionRec {
2146
__DRIextension base;
2147
2148
/* Common DRI functions, shared with DRI2 */
2149
__DRIcreateNewScreen2Func createNewScreen2;
2150
__DRIcreateNewDrawableFunc createNewDrawable;
2151
__DRIcreateContextAttribsFunc createContextAttribs;
2152
__DRIgetAPIMaskFunc getAPIMask;
2153
};
2154
2155
/**
2156
* Background callable loader extension.
2157
*
2158
* Loaders expose this extension to indicate to drivers that they are capable
2159
* of handling callbacks from the driver's background drawing threads.
2160
*/
2161
#define __DRI_BACKGROUND_CALLABLE "DRI_BackgroundCallable"
2162
#define __DRI_BACKGROUND_CALLABLE_VERSION 1
2163
2164
typedef struct __DRIbackgroundCallableExtensionRec __DRIbackgroundCallableExtension;
2165
struct __DRIbackgroundCallableExtensionRec {
2166
__DRIextension base;
2167
2168
/**
2169
* Indicate that this thread is being used by the driver as a background
2170
* drawing thread which may make callbacks to the loader.
2171
*
2172
* \param loaderPrivate is the value that was passed to to the driver when
2173
* the context was created. This can be used by the loader to identify
2174
* which context any callbacks are associated with.
2175
*
2176
* If this function is called more than once from any given thread, each
2177
* subsequent call overrides the loaderPrivate data that was passed in the
2178
* previous call. The driver can take advantage of this to re-use a
2179
* background thread to perform drawing on behalf of multiple contexts.
2180
*
2181
* It is permissible for the driver to call this function from a
2182
* non-background thread (i.e. a thread that has already been bound to a
2183
* context using __DRIcoreExtensionRec::bindContext()); when this happens,
2184
* the \c loaderPrivate pointer must be equal to the pointer that was
2185
* passed to the driver when the currently bound context was created.
2186
*
2187
* This call should execute quickly enough that the driver can call it with
2188
* impunity whenever a background thread starts performing drawing
2189
* operations (e.g. it should just set a thread-local variable).
2190
*/
2191
void (*setBackgroundContext)(void *loaderPrivate);
2192
2193
/**
2194
* Indicate that it is multithread safe to use glthread. For GLX/EGL
2195
* platforms using Xlib, that involves calling XInitThreads, before
2196
* opening an X display.
2197
*
2198
* Note: only supported if extension version is at least 2.
2199
*
2200
* \param loaderPrivate is the value that was passed to to the driver when
2201
* the context was created. This can be used by the loader to identify
2202
* which context any callbacks are associated with.
2203
*/
2204
GLboolean (*isThreadSafe)(void *loaderPrivate);
2205
};
2206
2207
/**
2208
* The driver portion of EGL_KHR_mutable_render_buffer.
2209
*
2210
* If the driver creates a __DRIconfig with
2211
* __DRI_ATTRIB_MUTABLE_RENDER_BUFFER, then it must support this extension.
2212
*
2213
* To support this extension:
2214
*
2215
* - The driver should create at least one __DRIconfig with
2216
* __DRI_ATTRIB_MUTABLE_RENDER_BUFFER. This is strongly recommended but
2217
* not required.
2218
*
2219
* - The driver must be able to handle __DRI_IMAGE_BUFFER_SHARED if
2220
* returned by __DRIimageLoaderExtension:getBuffers().
2221
*
2222
* - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must call
2223
* __DRImutableRenderBufferLoaderExtension::displaySharedBuffer() in
2224
* response to glFlush and glFinish. (This requirement is not documented
2225
* in EGL_KHR_mutable_render_buffer, but is a de-facto requirement in the
2226
* Android ecosystem. Android applications expect that glFlush will
2227
* immediately display the buffer when in shared buffer mode, and Android
2228
* drivers comply with this expectation). It :may: call
2229
* displaySharedBuffer() more often than required.
2230
*
2231
* - When rendering to __DRI_IMAGE_BUFFER_SHARED, it must ensure that the
2232
* buffer is always in a format compatible for display because the
2233
* display engine (usually SurfaceFlinger or hwcomposer) may display the
2234
* image at any time, even concurrently with 3D rendering. For example,
2235
* display hardware and the GL hardware may be able to access the buffer
2236
* simultaneously. In particular, if the buffer is compressed then take
2237
* care that SurfaceFlinger and hwcomposer can consume the compression
2238
* format.
2239
*
2240
* \see __DRI_IMAGE_BUFFER_SHARED
2241
* \see __DRI_ATTRIB_MUTABLE_RENDER_BUFFER
2242
* \see __DRI_MUTABLE_RENDER_BUFFER_LOADER
2243
*/
2244
#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER "DRI_MutableRenderBufferDriver"
2245
#define __DRI_MUTABLE_RENDER_BUFFER_DRIVER_VERSION 1
2246
2247
typedef struct __DRImutableRenderBufferDriverExtensionRec __DRImutableRenderBufferDriverExtension;
2248
struct __DRImutableRenderBufferDriverExtensionRec {
2249
__DRIextension base;
2250
};
2251
2252
/**
2253
* The loader portion of EGL_KHR_mutable_render_buffer.
2254
*
2255
* Requires loader extension DRI_IMAGE_LOADER, through which the loader sends
2256
* __DRI_IMAGE_BUFFER_SHARED to the driver.
2257
*
2258
* \see __DRI_MUTABLE_RENDER_BUFFER_DRIVER
2259
*/
2260
#define __DRI_MUTABLE_RENDER_BUFFER_LOADER "DRI_MutableRenderBufferLoader"
2261
#define __DRI_MUTABLE_RENDER_BUFFER_LOADER_VERSION 1
2262
2263
typedef struct __DRImutableRenderBufferLoaderExtensionRec __DRImutableRenderBufferLoaderExtension;
2264
struct __DRImutableRenderBufferLoaderExtensionRec {
2265
__DRIextension base;
2266
2267
/**
2268
* Inform the display engine (that is, SurfaceFlinger and/or hwcomposer)
2269
* that the __DRIdrawable has new content.
2270
*
2271
* The display engine may ignore this call, for example, if it continually
2272
* refreshes and displays the buffer on every frame, as in
2273
* EGL_ANDROID_front_buffer_auto_refresh. On the other extreme, the display
2274
* engine may refresh and display the buffer only in frames in which the
2275
* driver calls this.
2276
*
2277
* If the fence_fd is not -1, then the display engine will display the
2278
* buffer only after the fence signals.
2279
*
2280
* The drawable's current __DRIimageBufferMask, as returned by
2281
* __DRIimageLoaderExtension::getBuffers(), must be
2282
* __DRI_IMAGE_BUFFER_SHARED.
2283
*/
2284
void (*displaySharedBuffer)(__DRIdrawable *drawable, int fence_fd,
2285
void *loaderPrivate);
2286
};
2287
2288
#endif
2289
2290