summaryrefslogtreecommitdiff
path: root/dri3proto.txt
blob: c267574554e11b7a0ccf3b330aee54aded7b7c92 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
			  The DRI3 Extension
			     Version 1.3
			      2021-11-30

			    Keith Packard
			  keithp@keithp.com
			  Intel Corporation

			    Daniel Stone
		       daniels@collabora.com
			     Collabora


1. Introduction

The DRI3 extension provides mechanisms to translate between direct
rendered buffers and X pixmaps. When combined with the Present extension,
a complete direct rendering solution for hardware-accelerated devices
such as GPUs is provided.

The direct rendered buffers are passed across the protocol via
standard POSIX file descriptor passing mechanisms. On Linux, these
buffers are DMA-BUF objects.

DRI3 also includes a mechanism to translate between Linux Futexes
and X Sync extension Fences. This provides a synchronization mechanism
which can be used to serialize access to shared render buffers.

1.1. Acknowledgments

Eric Anholt <eric@anholt.net>
Dave Airlie <airlied@redhat.com>
Kristian Høgsberg <krh@bitplanet.net>
James Jones <jajones@nvidia.com>
Arthur Huillet <arthur.huillet@free.fr>
Louis-Francis Ratté-Boulianne <lfrb@collabora.com>
Austin Shafer <ashafer@nvidia.com>

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

2. Data Types

The DRI3 extension uses the RandR extension Provider data type to
select among multiple GPUs on a single screen and the Sync extension
fence object to provide graphics object synchronization.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

4. Errors

DRI3 defines no errors.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

5. Events

DRI3 defines no events.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

6. Protocol Types

DRI3 defines no new protocol types.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

7. Extension Initialization

The name of this extension is "DRI3"

┌───
    DRI3QueryVersion
	client-major-version:	CARD32
	client-minor-version:	CARD32
      ▶
	major-version:		CARD32
	minor-version:		CARD32
└───

	The client sends the highest supported version to the server
	and the server sends the highest version it supports, but no
	higher than the requested version. Major versions changes can
	introduce incompatibilities in existing functionality, minor
	version changes introduce only backward compatible changes.
	It is the clients responsibility to ensure that the server
	supports a version which is compatible with its expectations.

	Backwards compatible changes included addition of new
	requests.


			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 

8. Extension Requests

┌───
    DRI3Open
	drawable: DRAWABLE
	provider: PROVIDER
      ▶
	nfd: CARD8
	device: FD
└───
	Errors: Drawable, Value, Match

	This requests that the X server open the direct rendering
	device associated with drawable and RandR provider. The
	provider must support SourceOutput or SourceOffload.

	The file descriptor for the device is returned in
	'device'. 'nfd' will be set to one (this is strictly a
	convenience for XCB which otherwise would need
	request-specific information about how many file descriptors
	were associated with this reply).

┌───
    DRI3PixmapFromBuffer
	pixmap: PIXMAP
	drawable: DRAWABLE
	size: CARD32
	width, height, stride: CARD16
	depth, bpp: CARD8
	buffer: FD
└───
	Errors: Alloc, Drawable, IDChoice, Value, Match

	Creates a pixmap for the direct rendering object associated
	with 'buffer' and the screen associated with 'drawable'.
	Changes to pixmap will be visible in that direct rendered
	object and changes to the direct rendered object will be
	visible in the pixmap.

	'size' specifies the total size of the buffer bytes. 'width',
	'height' describe the geometry (in pixels) of the underlying
	buffer. 'stride' specifies the number of bytes per scanline in
	the buffer. The pixels within the buffer are not required to
	be arranged in a simple linear fashion, but 'size' will be at
	least 'height' * 'stride'.

	Precisely how any additional information about the buffer is
	shared is outside the scope of this extension.

	If buffer cannot be used with the screen associated with
	drawable, a Match error is returned.

	If depth or bpp are not supported by the screen, a Value error
	is returned.

	For information on synchronization of buffer access between
	the client and the X server, please see section 12.

┌───
    DRI3BufferFromPixmap
	pixmap: PIXMAP
      ▶
	nfd: CARD8
	size: CARD32
	width, height, stride: CARD16
	depth, bpp: CARD8
	buffer: FD
└───
	Errors: Pixmap, Match

	Pass back a direct rendering object associated with
	pixmap. Changes to pixmap will be visible in that
	direct rendered object and changes to the direct rendered
	object will be visible in the pixmap.

	'size' specifies the total size of the buffer bytes. 'width',
	'height' describe the geometry (in pixels) of the underlying
	buffer. 'stride' specifies the number of bytes per scanline in
	the buffer. The pixels within the buffer are not required to
	be arranged in a simple linear fashion, but 'size' will be at
	least 'height' * 'stride'.

	Precisely how any additional information about the buffer is
	shared is outside the scope of this extension.

	If buffer cannot be used with the screen associated with
	drawable, a Match error is returned.

	For information on synchronization of buffer access between
	the client and the X server, please see section 12.

┌───
    DRI3FenceFromFD
	drawable: DRAWABLE
	fence: FENCE
	initially-triggered: BOOL
	fd: FD
└───
	Errors: IDchoice, Drawable

	Creates a Sync extension Fence that provides the regular Sync
	extension semantics along with a file descriptor that provides
	a device-specific mechanism to manipulate the fence directly.
	Details about the mechanism used with this file descriptor are
	outside the scope of the DRI3 extension.

	For information on synchronization of buffer access between
	the client and the X server, please see section 12.

┌───
    DRI3FDFromFence
	drawable: DRAWABLE
	fence: FENCE
      ▶
	fd: FD
└───
	Errors: IDchoice, Drawable, Match

	Given a Sync extension Fence that provides the regular Sync
	extension semantics, returns a file descriptor that provides a
	device-specific mechanism to manipulate the fence directly.
	Details about the mechanism used with this file descriptor are
	outside the scope of the DRI3 extension. 'drawable' must be
	associated with a direct rendering device that 'fence' can
	work with, otherwise a Match error results.

	For information on synchronization of buffer access between
	the client and the X server, please see section 12.

┌───
    DRI3GetSupportedModifiers
	window: WINDOW
	depth: CARD8
	bpp: CARD8
      ▶
	num_window_modifiers: CARD32
	num_screen_modifiers: CARD32
	window_modifiers: ListOfCARD64
	screen_modifiers: ListOfCARD64
└───
	Errors: Window, Match

	Return supported DRM FourCC modifiers for the specified
	'window'.

	The first list of 'window_modifiers' contains a set of
	modifiers which the server considers optimal for the window's
	current configuration. Using these modifiers to allocate, even
	if locally suboptimal to the client driver, may result in a
	more optimal display pipeline, e.g. by avoiding composition.

	The second list of 'screen_modifiers', is the total set of
	modifiers which are acceptable for use on the Screen associated
	with 'window'. This set of modifiers will not change over the
	lifetime of the client. Using this set of modifiers to allocate
	may not result in a globally optimal pipeline, if separate
	'window_modifiers' are available.

	It is expected that a client calling this request will obtain
	the modifiers for a particular window, allocate buffers using
	the preferred modifier set as described above, create a Pixmap
	referring to the storage of those buffers using the
	DRI3BuffersFromPixmap request, then make the content visible
	in the storage of those buffers visible with a request such as
	the Present extension's PresentPixmap.

	The meaning of any modifier is canonically defined in
	drm_fourcc.h.

┌───
    DRI3PixmapFromBuffers
	pixmap: PIXMAP
	window: WINDOW
	num_buffers: CARD8
	width, height: CARD16
	stride0, offset0: CARD32
	stride1, offset1: CARD32
	stride2, offset2: CARD32
	stride3, offset3: CARD32
	depth, bpp: CARD8
	modifier: CARD64
	buffers: ListOfFD
└───
	Errors: Alloc, Window, IDChoice, Value, Match

	Creates a pixmap for the direct rendering object associated
	with 'buffers' and the screen associated with 'window'.
	Changes to pixmap will be visible in that direct rendered
	object and changes to the direct rendered object will be
	visible in the pixmap. The pixmap will be available for
	presentation to the window.

	In contrast to PixmapFromBuffer, multiple buffers may be
	combined to specify a single logical source for pixel
	sampling: 'num_buffers' may be set from 1 (single buffer,
	akin to PixmapFromBuffer) to 4. This is the number of file
	descriptors which will be sent with this request; one per
	buffer.

	Modifiers allow explicit specification of non-linear sources,
	such as tiled or compressed buffers. The combination of bpp,
	depth, and modifier allows unambiguous declaration of the
	buffer layout in a manner defined by the DRM tokens.

	If 'modifier' is DRM_FORMAT_MOD_INVALID, the client does
	not have information on the buffer layout. In this case, the
	buffer may only have a single plane. The driver may make its
	own inference through unspecified means to determine the exact
	buffer layout, however this is neither required nor defined
	by the specification, and is considered an implementation
	detail of the particular driver.

	'width' and 'height' describe the geometry (in pixels) of the
	logical pixel-sample source.

	'strideN' and 'offsetN' define the number of bytes per logical
	scanline, and the distance in bytes from the beginning of the
	buffer passed for that plane until the start of the sample
	source for that plane, respectively for plane N. If the plane
	is not used according to the format and modifier specification,
	both values for that plane must be zero.

	Precisely how any additional information about the buffer (such
	as memory placement) is shared is outside the scope of this
	extension.

	If the buffer(s) cannot be used with the screen associated with
	'window', a Match error is returned.

	If the bpp, depth, and modifier combination is not supported by
	the screen, a Value error is returned.

	For information on synchronization of buffer access between
	the client and the X server, please see section 12.

┌───
    DRI3BuffersFromPixmap
	pixmap: PIXMAP
      ▶
	nfd: CARD8
	width, height: CARD16
	depth, bpp: CARD8
	modifier: CARD64
	strides: ListOfCARD32
	offsets: ListOfCARD32
	buffers: ListOfFD
└───
	Errors: Pixmap, Match

	Returns direct rendering objects associated with 'pixmap'.
	Changes to 'pixmap' will be visible in the direct rendered
	objects and changes to the direct rendered objects will be
	visible in 'pixmap' after flushing and synchronization.

	'width' and 'height' describe the geometry (in pixels) of the
	logical pixel-sample source from combining the direct rendering
	objects.

	See PixmapFromBuffers for more details on DRM modifiers usage.

	'nfd' describes the number of buffers returned for the pixmap,
	which must be combined together according to 'depth', 'bpp', and
	'modifier'.

	For each buffer, there is an entry in the 'strides',
	'offsets', and 'buffers' list. 'buffer' contains a single file
	descriptor referring to the buffer. 'stride' specifies the
	number of bytes per logical scanline for this plane, and
	'offset' specifies the distance in bytes from the beginning
	of 'buffer' until the start of the sample source for that
	plane.

	Precisely how any additional information about the buffer is
	shared is outside the scope of this extension.

	If buffers cannot be exported from the the screen associated
	with 'pixmap', a Match error is returned.

	For information on synchronization of buffer access between
	the client and the X server, please see section 12.

┌───
    DRI3SetDRMDeviceInUse
	window: WINDOW
	drmMajor: CARD32
	drmMinor: CARD32
└───
	Errors: Window

	This request provides a hint to the server about the device
	in use by this window. This is used to provide
	DRI3GetSupportedModifiers with a hint of what device to
	return modifiers for in the window_modifiers return value.
	Using this hint allows for device-specific modifiers to
	be returned by DRI3GetSupportedModifiers, for example
	when an application is renderoffloaded and eligible for
	direct scanout.

	This is only a hint, and may or may not be reflected in
	the modifier list returned.

	If the window specified was not found, a Window error will
	be returned.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄

9. Extension Events

DRI3 defines no events.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄

10. Extension Versioning

The DRI3 extension is adapted from the DRI2 extension.

	1.0: First published version

	1.1: Cosmetic changes

	1.2: Add GetSupportedModifiers,
	     PixmapFromBuffers, and BuffersFromPixmap requests.

	1.3: Add SetDRMDeviceInUse

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄


11. Relationship with other extensions

As an extension designed to support other extensions, there is
naturally some interactions with other extensions.

11.1 GLX

GLX is both an application interface and an X extension. OpenGL
applications using the GLX API will use the GLX extension, DRI3 and
Present when doing direct rendering.

11.2 Present

The Present extension provides a way to synchronize the display of pixmap
contents to the screen. When used in conjunction with DRI3, they
provide a complete direct rendering solution for OpenGL or other APIs.

11.3 DRI2

DRI3 provides similar functionality to the DRI2Connect and
DRI2GetBuffersWithFormat requests, however DRI3 uses file descriptors
to refer to the direct rendering device and buffers.

Present and DRI3 are designed in conjunction to replace DRI2

11.2 XvMC / Xv

It might be nice to be able to reference YUV formatted direct rendered
objects from the X server.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄

12. Synchronization

Synchronization of access to buffers shared between processes is not
currently explicitly controlled by this protocol.

Without the use of additional extensions not defined by the DRI3
protocol as of version 1.2, synchronization between multiple
processes and contexts is considered to follow the implicit model.

In this model, the driver is required to have a global view of
access requests issued by all processes with a reference to the
buffer, and control scheduling of all operations on that buffer,
whether performed by the CPU or auxiliary hardware.

The driver is responsible for enforcing a strict ordering to protect
against write-after-read or read-after-write hazards, such that any
reads requested by one process or context, are fulfilled before any
writes requested by another process or context, as long as that read
was definitively submitted before the write.

A similar dependency exists for reads submitted after writes: the
driver must ensure that the write is fully visible and coherent to
the read request.

As a purely illustrative example, if two processes share a buffer,
where one process reads from a buffer using an OpenGL texture
sampler and submits this work by calling 'glFlush', and the other
process submits work to the driver to write to that buffer, the
driver is responsible for ensuring that the results of the latter
write are not visible to the texture sampler.

The Sync fences provided by DRI3 control only this submission of
work and ensuing global visibility of the requests, rather than the
completion of the work within any hardware. To further the example
above, a fence used to prevent any writes to the buffer before the
sampler had completed access, the fence would be signaled when
'glFlush' had been called, at which point the request has become
globally visible to the driver's request-scheduling and
synchronization mechanisms. The logical ordering of requests made
by software has been preserved, and the driver then takes care
to ensure that these requests are scheduled such they do not
observe effects from requests made later in time.

This presents a fully coherent in-order FIFO-like model across
processes, where synchronzation is handled externally to the DRI3
client with no explicit intervention.

This restriction also applies for cross-device usage.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄

Appendix A. Protocol Encoding

Syntactic Conventions

This document uses the same syntactic conventions as the core X
protocol encoding document.


A.1 Common Types

None.

A.2 Protocol Requests

┌───
    DRI3QueryVersion
	1	CARD8			major opcode
	1	0			DRI3 opcode
	2	3			length
	4	CARD32			major version
	4	CARD32			minor version
      ▶
	1	1			Reply
        1				unused
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			major version
        4	CARD32			minor version
	16				unused	
└───


┌───
    DRI3Open
	1	CARD8			major opcode
	1	1			DRI3 opcode
	2	4			length
	4	DRAWABLE		drawable
	4	PROVIDER		provider
      ▶	
	1	1			Reply
        1	1			nfd
	2	CARD16			sequence number
	4	0			reply length
	24				unused

	0	FD			device
└───

┌───
    DRI3PixmapFromBuffer
	1	CARD8			major opcode
	1	2			DRI3 opcode
	2	6			length
	4	Pixmap			pixmap
	4	Drawable		drawable
	4	CARD32			size
	2	CARD16			width
	2	CARD16			height
	2	CARD16			stride
	1	CARD8			depth
	1	CARD8			bpp

	0	FD			buffer
└───

┌───
    DRI3BufferFromPixmap
	1	CARD8			major opcode
	1	3			DRI3 opcode
	2	2			length
	4	Pixmap			pixmap
      ▶	
	1	1			Reply
        1	1			nfd
	2	CARD16			sequence number
	4	0			reply length
	4	CARD32			size
	2	CARD16			width
	2	CARD16			height
	2	CARD16			stride
	1	CARD8			depth
	1	CARD8			bpp
	12				unused

	0	FD			buffer
└───

┌───
    DRI3FenceFromFD
	1	CARD8			major opcode
	1	4			DRI3 opcode
	2	4			length
	4	Drawable		drawable
	4	Fence			fence
	1	BOOL			initially triggered
	3				unused

	0	FD			fence fd
└───

┌───
    DRI3FDFromFence
	1	CARD8			major opcode
	1	5			DRI3 opcode
	2	3			length
	4	Drawable		drawable
	4	Fence			fence
      ▶	
	1	1			Reply
        1	1			nfd
	2	CARD16			sequence number
	4	0			reply length
	24				unused

	0	FD			fence fd
└───

┌───
    DRI3GetSupportedModifiers
	1	CARD8			major opcode
	1	7			DRI3 opcode
	2	3			length
	4	Window			window
	1	CARD8			depth
	1	CARD8			bpp
	2				unused
      ▶
	1	1			Reply
        1	0			unused
	2	CARD16			sequence number
	4	CARD32			reply length
	4	CARD32			num_window_modifiers
	4	CARD32			num_screen_modifiers
	16				unused

	4	ListOfCARD64		window_modifiers[num_window_modifiers]
	4	ListOfCARD64		screen_modifiers[num_screen_modifiers]
└───

┌───
    DRI3PixmapFromBuffers
	1	CARD8			major opcode
	1	8			DRI3 opcode
	2	8			length
	4	Pixmap			pixmap
	4	Window			window
	1	CARD8			num_buffers
	3				unused
	2	CARD16			width
	2	CARD16			height
	4	CARD32			stride0
	4	CARD32			offset0
	4	CARD32			stride1
	4	CARD32			offset1
	4	CARD32			stride2
	4	CARD32			offset2
	4	CARD32			stride3
	4	CARD32			offset3
	1	CARD8			depth
	1	CARD8			bpp
	2				unused
	8	CARD64			modifier

	0	ListOfFD		buffers[num_buffers]
└───

┌───
    DRI3BuffersFromPixmap
	1	CARD8			major opcode
	1	9			DRI3 opcode
	2	2			length
	4	Pixmap			pixmap
      ▶
	1	1			Reply
        1	CARD8			nfd
	2	CARD16			sequence number
	4	CARD32			reply length
	2	CARD16			width
	2	CARD16			height
	4	CARD8			unused
	8	CARD64			modifier
	1	CARD8			depth
	1	CARD8			bpp
	6				unused

	0	ListOfFD		buffer[nfd]
	4	ListOfCARD32		strides[nfd]
	4	ListOfCARD32		offsets[nfd]
└───

┌───
    DRI3SetDRMDeviceInUse
	1	CARD8			major opcode
	1	10			DRI3 opcode
	2	4			length
	4	Window			window
	4	CARD32			drmMajor
	4	CARD32			drmMinor
└───

A.3 Protocol Events

The DRI3 extension defines no events.

A.4 Protocol Errors

The DRI3 extension defines no errors.

			     ❄ ❄ ❄  ❄  ❄ ❄ ❄