117ca54c3Smrg			  The DRI3 Extension
2635a5eb8Smrg			     Version 1.4
3452262e1Smrg			      2021-11-30
417ca54c3Smrg
517ca54c3Smrg			    Keith Packard
617ca54c3Smrg			  keithp@keithp.com
717ca54c3Smrg			  Intel Corporation
817ca54c3Smrg
917ca54c3Smrg			    Daniel Stone
1017ca54c3Smrg		       daniels@collabora.com
1117ca54c3Smrg			     Collabora
1217ca54c3Smrg
1317ca54c3Smrg
1417ca54c3Smrg1. Introduction
1517ca54c3Smrg
1617ca54c3SmrgThe DRI3 extension provides mechanisms to translate between direct
1717ca54c3Smrgrendered buffers and X pixmaps. When combined with the Present extension,
1817ca54c3Smrga complete direct rendering solution for hardware-accelerated devices
1917ca54c3Smrgsuch as GPUs is provided.
2017ca54c3Smrg
2117ca54c3SmrgThe direct rendered buffers are passed across the protocol via
2217ca54c3Smrgstandard POSIX file descriptor passing mechanisms. On Linux, these
2317ca54c3Smrgbuffers are DMA-BUF objects.
2417ca54c3Smrg
2517ca54c3SmrgDRI3 also includes a mechanism to translate between Linux Futexes
2617ca54c3Smrgand X Sync extension Fences. This provides a synchronization mechanism
2717ca54c3Smrgwhich can be used to serialize access to shared render buffers.
2817ca54c3Smrg
2917ca54c3Smrg1.1. Acknowledgments
3017ca54c3Smrg
3117ca54c3SmrgEric Anholt <eric@anholt.net>
3217ca54c3SmrgDave Airlie <airlied@redhat.com>
3317ca54c3SmrgKristian Høgsberg <krh@bitplanet.net>
3417ca54c3SmrgJames Jones <jajones@nvidia.com>
3517ca54c3SmrgArthur Huillet <arthur.huillet@free.fr>
3617ca54c3SmrgLouis-Francis Ratté-Boulianne <lfrb@collabora.com>
37452262e1SmrgAustin Shafer <ashafer@nvidia.com>
3817ca54c3Smrg
3917ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
4017ca54c3Smrg
4117ca54c3Smrg2. Data Types
4217ca54c3Smrg
4317ca54c3SmrgThe DRI3 extension uses the RandR extension Provider data type to
4417ca54c3Smrgselect among multiple GPUs on a single screen and the Sync extension
4517ca54c3Smrgfence object to provide graphics object synchronization.
4617ca54c3Smrg
4717ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
4817ca54c3Smrg
4917ca54c3Smrg4. Errors
5017ca54c3Smrg
5117ca54c3SmrgDRI3 defines no errors.
5217ca54c3Smrg
5317ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
5417ca54c3Smrg
5517ca54c3Smrg5. Events
5617ca54c3Smrg
5717ca54c3SmrgDRI3 defines no events.
5817ca54c3Smrg
5917ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
6017ca54c3Smrg
6117ca54c3Smrg6. Protocol Types
6217ca54c3Smrg
63635a5eb8SmrgSYNCOBJ { XID }
6417ca54c3Smrg
6517ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
6617ca54c3Smrg
6717ca54c3Smrg7. Extension Initialization
6817ca54c3Smrg
6917ca54c3SmrgThe name of this extension is "DRI3"
7017ca54c3Smrg
7117ca54c3Smrg┌───
7217ca54c3Smrg    DRI3QueryVersion
7317ca54c3Smrg	client-major-version:	CARD32
7417ca54c3Smrg	client-minor-version:	CARD32
7517ca54c3Smrg7617ca54c3Smrg	major-version:		CARD32
7717ca54c3Smrg	minor-version:		CARD32
7817ca54c3Smrg└───
7917ca54c3Smrg
8017ca54c3Smrg	The client sends the highest supported version to the server
8117ca54c3Smrg	and the server sends the highest version it supports, but no
8217ca54c3Smrg	higher than the requested version. Major versions changes can
8317ca54c3Smrg	introduce incompatibilities in existing functionality, minor
8417ca54c3Smrg	version changes introduce only backward compatible changes.
8517ca54c3Smrg	It is the clients responsibility to ensure that the server
8617ca54c3Smrg	supports a version which is compatible with its expectations.
8717ca54c3Smrg
8817ca54c3Smrg	Backwards compatible changes included addition of new
8917ca54c3Smrg	requests.
9017ca54c3Smrg
9117ca54c3Smrg
9217ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
9317ca54c3Smrg
9417ca54c3Smrg8. Extension Requests
9517ca54c3Smrg
9617ca54c3Smrg┌───
9717ca54c3Smrg    DRI3Open
9817ca54c3Smrg	drawable: DRAWABLE
9917ca54c3Smrg	provider: PROVIDER
10017ca54c3Smrg10117ca54c3Smrg	nfd: CARD8
10217ca54c3Smrg	device: FD
10317ca54c3Smrg└───
10417ca54c3Smrg	Errors: Drawable, Value, Match
10517ca54c3Smrg
10617ca54c3Smrg	This requests that the X server open the direct rendering
10717ca54c3Smrg	device associated with drawable and RandR provider. The
10817ca54c3Smrg	provider must support SourceOutput or SourceOffload.
10917ca54c3Smrg
11017ca54c3Smrg	The file descriptor for the device is returned in
11117ca54c3Smrg	'device'. 'nfd' will be set to one (this is strictly a
11217ca54c3Smrg	convenience for XCB which otherwise would need
11317ca54c3Smrg	request-specific information about how many file descriptors
11417ca54c3Smrg	were associated with this reply).
11517ca54c3Smrg
11617ca54c3Smrg┌───
11717ca54c3Smrg    DRI3PixmapFromBuffer
11817ca54c3Smrg	pixmap: PIXMAP
11917ca54c3Smrg	drawable: DRAWABLE
12017ca54c3Smrg	size: CARD32
12117ca54c3Smrg	width, height, stride: CARD16
12217ca54c3Smrg	depth, bpp: CARD8
12317ca54c3Smrg	buffer: FD
12417ca54c3Smrg└───
12517ca54c3Smrg	Errors: Alloc, Drawable, IDChoice, Value, Match
12617ca54c3Smrg
12717ca54c3Smrg	Creates a pixmap for the direct rendering object associated
12817ca54c3Smrg	with 'buffer' and the screen associated with 'drawable'.
12917ca54c3Smrg	Changes to pixmap will be visible in that direct rendered
13017ca54c3Smrg	object and changes to the direct rendered object will be
13117ca54c3Smrg	visible in the pixmap.
13217ca54c3Smrg
13317ca54c3Smrg	'size' specifies the total size of the buffer bytes. 'width',
13417ca54c3Smrg	'height' describe the geometry (in pixels) of the underlying
13517ca54c3Smrg	buffer. 'stride' specifies the number of bytes per scanline in
13617ca54c3Smrg	the buffer. The pixels within the buffer are not required to
13717ca54c3Smrg	be arranged in a simple linear fashion, but 'size' will be at
13817ca54c3Smrg	least 'height' * 'stride'.
13917ca54c3Smrg
14017ca54c3Smrg	Precisely how any additional information about the buffer is
14117ca54c3Smrg	shared is outside the scope of this extension.
14217ca54c3Smrg
14317ca54c3Smrg	If buffer cannot be used with the screen associated with
14417ca54c3Smrg	drawable, a Match error is returned.
14517ca54c3Smrg
14617ca54c3Smrg	If depth or bpp are not supported by the screen, a Value error
14717ca54c3Smrg	is returned.
14817ca54c3Smrg
14917ca54c3Smrg	For information on synchronization of buffer access between
15017ca54c3Smrg	the client and the X server, please see section 12.
15117ca54c3Smrg
15217ca54c3Smrg┌───
15317ca54c3Smrg    DRI3BufferFromPixmap
15417ca54c3Smrg	pixmap: PIXMAP
15517ca54c3Smrg15617ca54c3Smrg	nfd: CARD8
15717ca54c3Smrg	size: CARD32
15817ca54c3Smrg	width, height, stride: CARD16
15917ca54c3Smrg	depth, bpp: CARD8
16017ca54c3Smrg	buffer: FD
16117ca54c3Smrg└───
16217ca54c3Smrg	Errors: Pixmap, Match
16317ca54c3Smrg
16417ca54c3Smrg	Pass back a direct rendering object associated with
16517ca54c3Smrg	pixmap. Changes to pixmap will be visible in that
16617ca54c3Smrg	direct rendered object and changes to the direct rendered
16717ca54c3Smrg	object will be visible in the pixmap.
16817ca54c3Smrg
16917ca54c3Smrg	'size' specifies the total size of the buffer bytes. 'width',
17017ca54c3Smrg	'height' describe the geometry (in pixels) of the underlying
17117ca54c3Smrg	buffer. 'stride' specifies the number of bytes per scanline in
17217ca54c3Smrg	the buffer. The pixels within the buffer are not required to
17317ca54c3Smrg	be arranged in a simple linear fashion, but 'size' will be at
17417ca54c3Smrg	least 'height' * 'stride'.
17517ca54c3Smrg
17617ca54c3Smrg	Precisely how any additional information about the buffer is
17717ca54c3Smrg	shared is outside the scope of this extension.
17817ca54c3Smrg
17917ca54c3Smrg	If buffer cannot be used with the screen associated with
18017ca54c3Smrg	drawable, a Match error is returned.
18117ca54c3Smrg
18217ca54c3Smrg	For information on synchronization of buffer access between
18317ca54c3Smrg	the client and the X server, please see section 12.
18417ca54c3Smrg
18517ca54c3Smrg┌───
18617ca54c3Smrg    DRI3FenceFromFD
18717ca54c3Smrg	drawable: DRAWABLE
18817ca54c3Smrg	fence: FENCE
18917ca54c3Smrg	initially-triggered: BOOL
19017ca54c3Smrg	fd: FD
19117ca54c3Smrg└───
19217ca54c3Smrg	Errors: IDchoice, Drawable
19317ca54c3Smrg
19417ca54c3Smrg	Creates a Sync extension Fence that provides the regular Sync
19517ca54c3Smrg	extension semantics along with a file descriptor that provides
19617ca54c3Smrg	a device-specific mechanism to manipulate the fence directly.
19717ca54c3Smrg	Details about the mechanism used with this file descriptor are
19817ca54c3Smrg	outside the scope of the DRI3 extension.
19917ca54c3Smrg
20017ca54c3Smrg	For information on synchronization of buffer access between
20117ca54c3Smrg	the client and the X server, please see section 12.
20217ca54c3Smrg
20317ca54c3Smrg┌───
20417ca54c3Smrg    DRI3FDFromFence
20517ca54c3Smrg	drawable: DRAWABLE
20617ca54c3Smrg	fence: FENCE
20717ca54c3Smrg20817ca54c3Smrg	fd: FD
20917ca54c3Smrg└───
21017ca54c3Smrg	Errors: IDchoice, Drawable, Match
21117ca54c3Smrg
21217ca54c3Smrg	Given a Sync extension Fence that provides the regular Sync
21317ca54c3Smrg	extension semantics, returns a file descriptor that provides a
21417ca54c3Smrg	device-specific mechanism to manipulate the fence directly.
21517ca54c3Smrg	Details about the mechanism used with this file descriptor are
21617ca54c3Smrg	outside the scope of the DRI3 extension. 'drawable' must be
21717ca54c3Smrg	associated with a direct rendering device that 'fence' can
21817ca54c3Smrg	work with, otherwise a Match error results.
21917ca54c3Smrg
22017ca54c3Smrg	For information on synchronization of buffer access between
22117ca54c3Smrg	the client and the X server, please see section 12.
22217ca54c3Smrg
22317ca54c3Smrg┌───
22417ca54c3Smrg    DRI3GetSupportedModifiers
22517ca54c3Smrg	window: WINDOW
22617ca54c3Smrg	depth: CARD8
22717ca54c3Smrg	bpp: CARD8
22817ca54c3Smrg22917ca54c3Smrg	num_window_modifiers: CARD32
23017ca54c3Smrg	num_screen_modifiers: CARD32
23117ca54c3Smrg	window_modifiers: ListOfCARD64
23217ca54c3Smrg	screen_modifiers: ListOfCARD64
23317ca54c3Smrg└───
23417ca54c3Smrg	Errors: Window, Match
23517ca54c3Smrg
23617ca54c3Smrg	Return supported DRM FourCC modifiers for the specified
23717ca54c3Smrg	'window'.
23817ca54c3Smrg
23917ca54c3Smrg	The first list of 'window_modifiers' contains a set of
24017ca54c3Smrg	modifiers which the server considers optimal for the window's
24117ca54c3Smrg	current configuration. Using these modifiers to allocate, even
24217ca54c3Smrg	if locally suboptimal to the client driver, may result in a
24317ca54c3Smrg	more optimal display pipeline, e.g. by avoiding composition.
24417ca54c3Smrg
24517ca54c3Smrg	The second list of 'screen_modifiers', is the total set of
24617ca54c3Smrg	modifiers which are acceptable for use on the Screen associated
24717ca54c3Smrg	with 'window'. This set of modifiers will not change over the
24817ca54c3Smrg	lifetime of the client. Using this set of modifiers to allocate
24917ca54c3Smrg	may not result in a globally optimal pipeline, if separate
25017ca54c3Smrg	'window_modifiers' are available.
25117ca54c3Smrg
25217ca54c3Smrg	It is expected that a client calling this request will obtain
25317ca54c3Smrg	the modifiers for a particular window, allocate buffers using
25417ca54c3Smrg	the preferred modifier set as described above, create a Pixmap
25517ca54c3Smrg	referring to the storage of those buffers using the
25617ca54c3Smrg	DRI3BuffersFromPixmap request, then make the content visible
25717ca54c3Smrg	in the storage of those buffers visible with a request such as
25817ca54c3Smrg	the Present extension's PresentPixmap.
25917ca54c3Smrg
26017ca54c3Smrg	The meaning of any modifier is canonically defined in
26117ca54c3Smrg	drm_fourcc.h.
26217ca54c3Smrg
26317ca54c3Smrg┌───
26417ca54c3Smrg    DRI3PixmapFromBuffers
26517ca54c3Smrg	pixmap: PIXMAP
26617ca54c3Smrg	window: WINDOW
26717ca54c3Smrg	num_buffers: CARD8
26817ca54c3Smrg	width, height: CARD16
26917ca54c3Smrg	stride0, offset0: CARD32
27017ca54c3Smrg	stride1, offset1: CARD32
27117ca54c3Smrg	stride2, offset2: CARD32
27217ca54c3Smrg	stride3, offset3: CARD32
27317ca54c3Smrg	depth, bpp: CARD8
27417ca54c3Smrg	modifier: CARD64
27517ca54c3Smrg	buffers: ListOfFD
27617ca54c3Smrg└───
27717ca54c3Smrg	Errors: Alloc, Window, IDChoice, Value, Match
27817ca54c3Smrg
27917ca54c3Smrg	Creates a pixmap for the direct rendering object associated
28017ca54c3Smrg	with 'buffers' and the screen associated with 'window'.
28117ca54c3Smrg	Changes to pixmap will be visible in that direct rendered
28217ca54c3Smrg	object and changes to the direct rendered object will be
28317ca54c3Smrg	visible in the pixmap. The pixmap will be available for
28417ca54c3Smrg	presentation to the window.
28517ca54c3Smrg
28617ca54c3Smrg	In contrast to PixmapFromBuffer, multiple buffers may be
28717ca54c3Smrg	combined to specify a single logical source for pixel
28817ca54c3Smrg	sampling: 'num_buffers' may be set from 1 (single buffer,
28917ca54c3Smrg	akin to PixmapFromBuffer) to 4. This is the number of file
29017ca54c3Smrg	descriptors which will be sent with this request; one per
29117ca54c3Smrg	buffer.
29217ca54c3Smrg
29317ca54c3Smrg	Modifiers allow explicit specification of non-linear sources,
29417ca54c3Smrg	such as tiled or compressed buffers. The combination of bpp,
29517ca54c3Smrg	depth, and modifier allows unambiguous declaration of the
29617ca54c3Smrg	buffer layout in a manner defined by the DRM tokens.
29717ca54c3Smrg
29817ca54c3Smrg	If 'modifier' is DRM_FORMAT_MOD_INVALID, the client does
29917ca54c3Smrg	not have information on the buffer layout. In this case, the
30017ca54c3Smrg	buffer may only have a single plane. The driver may make its
30117ca54c3Smrg	own inference through unspecified means to determine the exact
30217ca54c3Smrg	buffer layout, however this is neither required nor defined
30317ca54c3Smrg	by the specification, and is considered an implementation
30417ca54c3Smrg	detail of the particular driver.
30517ca54c3Smrg
30617ca54c3Smrg	'width' and 'height' describe the geometry (in pixels) of the
30717ca54c3Smrg	logical pixel-sample source.
30817ca54c3Smrg
30917ca54c3Smrg	'strideN' and 'offsetN' define the number of bytes per logical
31017ca54c3Smrg	scanline, and the distance in bytes from the beginning of the
31117ca54c3Smrg	buffer passed for that plane until the start of the sample
31217ca54c3Smrg	source for that plane, respectively for plane N. If the plane
31317ca54c3Smrg	is not used according to the format and modifier specification,
31417ca54c3Smrg	both values for that plane must be zero.
31517ca54c3Smrg
31617ca54c3Smrg	Precisely how any additional information about the buffer (such
31717ca54c3Smrg	as memory placement) is shared is outside the scope of this
31817ca54c3Smrg	extension.
31917ca54c3Smrg
32017ca54c3Smrg	If the buffer(s) cannot be used with the screen associated with
32117ca54c3Smrg	'window', a Match error is returned.
32217ca54c3Smrg
32317ca54c3Smrg	If the bpp, depth, and modifier combination is not supported by
32417ca54c3Smrg	the screen, a Value error is returned.
32517ca54c3Smrg
32617ca54c3Smrg	For information on synchronization of buffer access between
32717ca54c3Smrg	the client and the X server, please see section 12.
32817ca54c3Smrg
32917ca54c3Smrg┌───
33017ca54c3Smrg    DRI3BuffersFromPixmap
33117ca54c3Smrg	pixmap: PIXMAP
33217ca54c3Smrg33317ca54c3Smrg	nfd: CARD8
33417ca54c3Smrg	width, height: CARD16
33517ca54c3Smrg	depth, bpp: CARD8
33617ca54c3Smrg	modifier: CARD64
33717ca54c3Smrg	strides: ListOfCARD32
33817ca54c3Smrg	offsets: ListOfCARD32
33917ca54c3Smrg	buffers: ListOfFD
34017ca54c3Smrg└───
34117ca54c3Smrg	Errors: Pixmap, Match
34217ca54c3Smrg
34317ca54c3Smrg	Returns direct rendering objects associated with 'pixmap'.
34417ca54c3Smrg	Changes to 'pixmap' will be visible in the direct rendered
34517ca54c3Smrg	objects and changes to the direct rendered objects will be
34617ca54c3Smrg	visible in 'pixmap' after flushing and synchronization.
34717ca54c3Smrg
34817ca54c3Smrg	'width' and 'height' describe the geometry (in pixels) of the
34917ca54c3Smrg	logical pixel-sample source from combining the direct rendering
35017ca54c3Smrg	objects.
35117ca54c3Smrg
35217ca54c3Smrg	See PixmapFromBuffers for more details on DRM modifiers usage.
35317ca54c3Smrg
35417ca54c3Smrg	'nfd' describes the number of buffers returned for the pixmap,
35517ca54c3Smrg	which must be combined together according to 'depth', 'bpp', and
35617ca54c3Smrg	'modifier'.
35717ca54c3Smrg
35817ca54c3Smrg	For each buffer, there is an entry in the 'strides',
35917ca54c3Smrg	'offsets', and 'buffers' list. 'buffer' contains a single file
36017ca54c3Smrg	descriptor referring to the buffer. 'stride' specifies the
36117ca54c3Smrg	number of bytes per logical scanline for this plane, and
36217ca54c3Smrg	'offset' specifies the distance in bytes from the beginning
36317ca54c3Smrg	of 'buffer' until the start of the sample source for that
36417ca54c3Smrg	plane.
36517ca54c3Smrg
36617ca54c3Smrg	Precisely how any additional information about the buffer is
36717ca54c3Smrg	shared is outside the scope of this extension.
36817ca54c3Smrg
36917ca54c3Smrg	If buffers cannot be exported from the the screen associated
37017ca54c3Smrg	with 'pixmap', a Match error is returned.
37117ca54c3Smrg
37217ca54c3Smrg	For information on synchronization of buffer access between
37317ca54c3Smrg	the client and the X server, please see section 12.
37417ca54c3Smrg
375452262e1Smrg┌───
376452262e1Smrg    DRI3SetDRMDeviceInUse
377452262e1Smrg	window: WINDOW
378452262e1Smrg	drmMajor: CARD32
379452262e1Smrg	drmMinor: CARD32
380452262e1Smrg└───
381452262e1Smrg	Errors: Window
382452262e1Smrg
383452262e1Smrg	This request provides a hint to the server about the device
384452262e1Smrg	in use by this window. This is used to provide
385452262e1Smrg	DRI3GetSupportedModifiers with a hint of what device to
386452262e1Smrg	return modifiers for in the window_modifiers return value.
387452262e1Smrg	Using this hint allows for device-specific modifiers to
388452262e1Smrg	be returned by DRI3GetSupportedModifiers, for example
389452262e1Smrg	when an application is renderoffloaded and eligible for
390452262e1Smrg	direct scanout.
391452262e1Smrg
392452262e1Smrg	This is only a hint, and may or may not be reflected in
393452262e1Smrg	the modifier list returned.
394452262e1Smrg
395452262e1Smrg	If the window specified was not found, a Window error will
396452262e1Smrg	be returned.
39717ca54c3Smrg
398635a5eb8Smrg
399635a5eb8Smrg┌───
400635a5eb8Smrg    DRI3ImportSyncobj
401635a5eb8Smrg	syncobj: SYNCOBJ
402635a5eb8Smrg	drawable: DRAWABLE
403635a5eb8Smrg	fd: FD
404635a5eb8Smrg└───
405635a5eb8Smrg	Errors: IDchoice, Drawable
406635a5eb8Smrg
407635a5eb8Smrg	Imports the DRM synchronization object bound to the given 'fd'.  This
408635a5eb8Smrg	may then be used to enable explicit synchronization with the
409635a5eb8Smrg	server-side direct rendering device associated with 'drawable'.
410635a5eb8Smrg
411635a5eb8Smrg	The provided syncobj must be a timeline syncobj.
412635a5eb8Smrg
413635a5eb8Smrg	If 'drawable' is not found, a Drawable error will be returned.
414635a5eb8Smrg
415635a5eb8Smrg
416635a5eb8Smrg┌───
417635a5eb8Smrg    DRI3FreeSyncobj
418635a5eb8Smrg	syncobj: SYNCOBJ
419635a5eb8Smrg└───
420635a5eb8Smrg	Errors: Value
421635a5eb8Smrg
422635a5eb8Smrg	Indicates that any resources associated with the given 'syncobj' should
423635a5eb8Smrg	be released by the server. The actual release may be deferred until any
424635a5eb8Smrg	pending operations that depend on the object have completed.
425635a5eb8Smrg
426635a5eb8Smrg	If 'syncobj' is not found, a Value error will be returned.
427635a5eb8Smrg
42817ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
42917ca54c3Smrg
43017ca54c3Smrg9. Extension Events
43117ca54c3Smrg
43217ca54c3SmrgDRI3 defines no events.
43317ca54c3Smrg
43417ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
43517ca54c3Smrg
43617ca54c3Smrg10. Extension Versioning
43717ca54c3Smrg
43817ca54c3SmrgThe DRI3 extension is adapted from the DRI2 extension.
43917ca54c3Smrg
44017ca54c3Smrg	1.0: First published version
44117ca54c3Smrg
44217ca54c3Smrg	1.1: Cosmetic changes
44317ca54c3Smrg
44417ca54c3Smrg	1.2: Add GetSupportedModifiers,
44517ca54c3Smrg	     PixmapFromBuffers, and BuffersFromPixmap requests.
44617ca54c3Smrg
447452262e1Smrg	1.3: Add SetDRMDeviceInUse
448452262e1Smrg
44917ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
45017ca54c3Smrg
45117ca54c3Smrg
45217ca54c3Smrg11. Relationship with other extensions
45317ca54c3Smrg
45417ca54c3SmrgAs an extension designed to support other extensions, there is
45517ca54c3Smrgnaturally some interactions with other extensions.
45617ca54c3Smrg
45717ca54c3Smrg11.1 GLX
45817ca54c3Smrg
45917ca54c3SmrgGLX is both an application interface and an X extension. OpenGL
46017ca54c3Smrgapplications using the GLX API will use the GLX extension, DRI3 and
46117ca54c3SmrgPresent when doing direct rendering.
46217ca54c3Smrg
46317ca54c3Smrg11.2 Present
46417ca54c3Smrg
46517ca54c3SmrgThe Present extension provides a way to synchronize the display of pixmap
46617ca54c3Smrgcontents to the screen. When used in conjunction with DRI3, they
46717ca54c3Smrgprovide a complete direct rendering solution for OpenGL or other APIs.
46817ca54c3Smrg
46917ca54c3Smrg11.3 DRI2
47017ca54c3Smrg
47117ca54c3SmrgDRI3 provides similar functionality to the DRI2Connect and
47217ca54c3SmrgDRI2GetBuffersWithFormat requests, however DRI3 uses file descriptors
47317ca54c3Smrgto refer to the direct rendering device and buffers.
47417ca54c3Smrg
47517ca54c3SmrgPresent and DRI3 are designed in conjunction to replace DRI2
47617ca54c3Smrg
47717ca54c3Smrg11.2 XvMC / Xv
47817ca54c3Smrg
47917ca54c3SmrgIt might be nice to be able to reference YUV formatted direct rendered
48017ca54c3Smrgobjects from the X server.
48117ca54c3Smrg
48217ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
48317ca54c3Smrg
48417ca54c3Smrg12. Synchronization
48517ca54c3Smrg
48617ca54c3SmrgSynchronization of access to buffers shared between processes is not
48717ca54c3Smrgcurrently explicitly controlled by this protocol.
48817ca54c3Smrg
48917ca54c3SmrgWithout the use of additional extensions not defined by the DRI3
49017ca54c3Smrgprotocol as of version 1.2, synchronization between multiple
49117ca54c3Smrgprocesses and contexts is considered to follow the implicit model.
49217ca54c3Smrg
49317ca54c3SmrgIn this model, the driver is required to have a global view of
49417ca54c3Smrgaccess requests issued by all processes with a reference to the
49517ca54c3Smrgbuffer, and control scheduling of all operations on that buffer,
49617ca54c3Smrgwhether performed by the CPU or auxiliary hardware.
49717ca54c3Smrg
49817ca54c3SmrgThe driver is responsible for enforcing a strict ordering to protect
49917ca54c3Smrgagainst write-after-read or read-after-write hazards, such that any
50017ca54c3Smrgreads requested by one process or context, are fulfilled before any
50117ca54c3Smrgwrites requested by another process or context, as long as that read
50217ca54c3Smrgwas definitively submitted before the write.
50317ca54c3Smrg
50417ca54c3SmrgA similar dependency exists for reads submitted after writes: the
50517ca54c3Smrgdriver must ensure that the write is fully visible and coherent to
50617ca54c3Smrgthe read request.
50717ca54c3Smrg
50817ca54c3SmrgAs a purely illustrative example, if two processes share a buffer,
50917ca54c3Smrgwhere one process reads from a buffer using an OpenGL texture
51017ca54c3Smrgsampler and submits this work by calling 'glFlush', and the other
51117ca54c3Smrgprocess submits work to the driver to write to that buffer, the
51217ca54c3Smrgdriver is responsible for ensuring that the results of the latter
51317ca54c3Smrgwrite are not visible to the texture sampler.
51417ca54c3Smrg
51517ca54c3SmrgThe Sync fences provided by DRI3 control only this submission of
51617ca54c3Smrgwork and ensuing global visibility of the requests, rather than the
51717ca54c3Smrgcompletion of the work within any hardware. To further the example
51817ca54c3Smrgabove, a fence used to prevent any writes to the buffer before the
51917ca54c3Smrgsampler had completed access, the fence would be signaled when
52017ca54c3Smrg'glFlush' had been called, at which point the request has become
52117ca54c3Smrgglobally visible to the driver's request-scheduling and
52217ca54c3Smrgsynchronization mechanisms. The logical ordering of requests made
52317ca54c3Smrgby software has been preserved, and the driver then takes care
52417ca54c3Smrgto ensure that these requests are scheduled such they do not
52517ca54c3Smrgobserve effects from requests made later in time.
52617ca54c3Smrg
52717ca54c3SmrgThis presents a fully coherent in-order FIFO-like model across
52817ca54c3Smrgprocesses, where synchronzation is handled externally to the DRI3
52917ca54c3Smrgclient with no explicit intervention.
53017ca54c3Smrg
53117ca54c3SmrgThis restriction also applies for cross-device usage.
53217ca54c3Smrg
53317ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
53417ca54c3Smrg
53517ca54c3SmrgAppendix A. Protocol Encoding
53617ca54c3Smrg
53717ca54c3SmrgSyntactic Conventions
53817ca54c3Smrg
53917ca54c3SmrgThis document uses the same syntactic conventions as the core X
54017ca54c3Smrgprotocol encoding document.
54117ca54c3Smrg
54217ca54c3Smrg
54317ca54c3SmrgA.1 Common Types
54417ca54c3Smrg
54517ca54c3SmrgNone.
54617ca54c3Smrg
54717ca54c3SmrgA.2 Protocol Requests
54817ca54c3Smrg
54917ca54c3Smrg┌───
55017ca54c3Smrg    DRI3QueryVersion
55117ca54c3Smrg	1	CARD8			major opcode
55217ca54c3Smrg	1	0			DRI3 opcode
55317ca54c3Smrg	2	3			length
55417ca54c3Smrg	4	CARD32			major version
55517ca54c3Smrg	4	CARD32			minor version
55617ca54c3Smrg55717ca54c3Smrg	1	1			Reply
55817ca54c3Smrg        1				unused
55917ca54c3Smrg	2	CARD16			sequence number
56017ca54c3Smrg	4	0			reply length
56117ca54c3Smrg	4	CARD32			major version
56217ca54c3Smrg        4	CARD32			minor version
56317ca54c3Smrg	16				unused	
56417ca54c3Smrg└───
56517ca54c3Smrg
56617ca54c3Smrg
56717ca54c3Smrg┌───
56817ca54c3Smrg    DRI3Open
56917ca54c3Smrg	1	CARD8			major opcode
57017ca54c3Smrg	1	1			DRI3 opcode
57117ca54c3Smrg	2	4			length
57217ca54c3Smrg	4	DRAWABLE		drawable
57317ca54c3Smrg	4	PROVIDER		provider
57417ca54c3Smrg57517ca54c3Smrg	1	1			Reply
57617ca54c3Smrg        1	1			nfd
57717ca54c3Smrg	2	CARD16			sequence number
57817ca54c3Smrg	4	0			reply length
57917ca54c3Smrg	24				unused
58017ca54c3Smrg
58117ca54c3Smrg	0	FD			device
58217ca54c3Smrg└───
58317ca54c3Smrg
58417ca54c3Smrg┌───
58517ca54c3Smrg    DRI3PixmapFromBuffer
58617ca54c3Smrg	1	CARD8			major opcode
58717ca54c3Smrg	1	2			DRI3 opcode
58817ca54c3Smrg	2	6			length
58917ca54c3Smrg	4	Pixmap			pixmap
59017ca54c3Smrg	4	Drawable		drawable
59117ca54c3Smrg	4	CARD32			size
59217ca54c3Smrg	2	CARD16			width
59317ca54c3Smrg	2	CARD16			height
59417ca54c3Smrg	2	CARD16			stride
59517ca54c3Smrg	1	CARD8			depth
59617ca54c3Smrg	1	CARD8			bpp
59717ca54c3Smrg
59817ca54c3Smrg	0	FD			buffer
59917ca54c3Smrg└───
60017ca54c3Smrg
60117ca54c3Smrg┌───
60217ca54c3Smrg    DRI3BufferFromPixmap
60317ca54c3Smrg	1	CARD8			major opcode
60417ca54c3Smrg	1	3			DRI3 opcode
60517ca54c3Smrg	2	2			length
60617ca54c3Smrg	4	Pixmap			pixmap
60717ca54c3Smrg60817ca54c3Smrg	1	1			Reply
60917ca54c3Smrg        1	1			nfd
61017ca54c3Smrg	2	CARD16			sequence number
61117ca54c3Smrg	4	0			reply length
61217ca54c3Smrg	4	CARD32			size
61317ca54c3Smrg	2	CARD16			width
61417ca54c3Smrg	2	CARD16			height
61517ca54c3Smrg	2	CARD16			stride
61617ca54c3Smrg	1	CARD8			depth
61717ca54c3Smrg	1	CARD8			bpp
61817ca54c3Smrg	12				unused
61917ca54c3Smrg
62017ca54c3Smrg	0	FD			buffer
62117ca54c3Smrg└───
62217ca54c3Smrg
62317ca54c3Smrg┌───
62417ca54c3Smrg    DRI3FenceFromFD
62517ca54c3Smrg	1	CARD8			major opcode
62617ca54c3Smrg	1	4			DRI3 opcode
62717ca54c3Smrg	2	4			length
62817ca54c3Smrg	4	Drawable		drawable
62917ca54c3Smrg	4	Fence			fence
63017ca54c3Smrg	1	BOOL			initially triggered
63117ca54c3Smrg	3				unused
63217ca54c3Smrg
63317ca54c3Smrg	0	FD			fence fd
63417ca54c3Smrg└───
63517ca54c3Smrg
63617ca54c3Smrg┌───
63717ca54c3Smrg    DRI3FDFromFence
63817ca54c3Smrg	1	CARD8			major opcode
63917ca54c3Smrg	1	5			DRI3 opcode
64017ca54c3Smrg	2	3			length
64117ca54c3Smrg	4	Drawable		drawable
64217ca54c3Smrg	4	Fence			fence
64317ca54c3Smrg64417ca54c3Smrg	1	1			Reply
64517ca54c3Smrg        1	1			nfd
64617ca54c3Smrg	2	CARD16			sequence number
64717ca54c3Smrg	4	0			reply length
64817ca54c3Smrg	24				unused
64917ca54c3Smrg
65017ca54c3Smrg	0	FD			fence fd
65117ca54c3Smrg└───
65217ca54c3Smrg
65317ca54c3Smrg┌───
65417ca54c3Smrg    DRI3GetSupportedModifiers
65517ca54c3Smrg	1	CARD8			major opcode
65668872e7fSmrg	1	6			DRI3 opcode
65717ca54c3Smrg	2	3			length
65817ca54c3Smrg	4	Window			window
65917ca54c3Smrg	1	CARD8			depth
66017ca54c3Smrg	1	CARD8			bpp
66117ca54c3Smrg	2				unused
66217ca54c3Smrg66317ca54c3Smrg	1	1			Reply
66417ca54c3Smrg        1	0			unused
66517ca54c3Smrg	2	CARD16			sequence number
66617ca54c3Smrg	4	CARD32			reply length
66717ca54c3Smrg	4	CARD32			num_window_modifiers
66817ca54c3Smrg	4	CARD32			num_screen_modifiers
66917ca54c3Smrg	16				unused
67017ca54c3Smrg
67117ca54c3Smrg	4	ListOfCARD64		window_modifiers[num_window_modifiers]
67217ca54c3Smrg	4	ListOfCARD64		screen_modifiers[num_screen_modifiers]
67317ca54c3Smrg└───
67417ca54c3Smrg
67517ca54c3Smrg┌───
67617ca54c3Smrg    DRI3PixmapFromBuffers
67717ca54c3Smrg	1	CARD8			major opcode
67868872e7fSmrg	1	7			DRI3 opcode
67917ca54c3Smrg	2	8			length
68017ca54c3Smrg	4	Pixmap			pixmap
68117ca54c3Smrg	4	Window			window
68217ca54c3Smrg	1	CARD8			num_buffers
68317ca54c3Smrg	3				unused
68417ca54c3Smrg	2	CARD16			width
68517ca54c3Smrg	2	CARD16			height
68617ca54c3Smrg	4	CARD32			stride0
68717ca54c3Smrg	4	CARD32			offset0
68817ca54c3Smrg	4	CARD32			stride1
68917ca54c3Smrg	4	CARD32			offset1
69017ca54c3Smrg	4	CARD32			stride2
69117ca54c3Smrg	4	CARD32			offset2
69217ca54c3Smrg	4	CARD32			stride3
69317ca54c3Smrg	4	CARD32			offset3
69417ca54c3Smrg	1	CARD8			depth
69517ca54c3Smrg	1	CARD8			bpp
69617ca54c3Smrg	2				unused
69717ca54c3Smrg	8	CARD64			modifier
69817ca54c3Smrg
69917ca54c3Smrg	0	ListOfFD		buffers[num_buffers]
70017ca54c3Smrg└───
70117ca54c3Smrg
70217ca54c3Smrg┌───
70317ca54c3Smrg    DRI3BuffersFromPixmap
70417ca54c3Smrg	1	CARD8			major opcode
70568872e7fSmrg	1	8			DRI3 opcode
70617ca54c3Smrg	2	2			length
70717ca54c3Smrg	4	Pixmap			pixmap
70817ca54c3Smrg70917ca54c3Smrg	1	1			Reply
71017ca54c3Smrg        1	CARD8			nfd
71117ca54c3Smrg	2	CARD16			sequence number
71217ca54c3Smrg	4	CARD32			reply length
71317ca54c3Smrg	2	CARD16			width
71417ca54c3Smrg	2	CARD16			height
71517ca54c3Smrg	4	CARD8			unused
71617ca54c3Smrg	8	CARD64			modifier
71717ca54c3Smrg	1	CARD8			depth
71817ca54c3Smrg	1	CARD8			bpp
71917ca54c3Smrg	6				unused
72017ca54c3Smrg
72117ca54c3Smrg	0	ListOfFD		buffer[nfd]
72217ca54c3Smrg	4	ListOfCARD32		strides[nfd]
72317ca54c3Smrg	4	ListOfCARD32		offsets[nfd]
72417ca54c3Smrg└───
72517ca54c3Smrg
726452262e1Smrg┌───
727452262e1Smrg    DRI3SetDRMDeviceInUse
728452262e1Smrg	1	CARD8			major opcode
72968872e7fSmrg	1	9			DRI3 opcode
730452262e1Smrg	2	4			length
731452262e1Smrg	4	Window			window
732452262e1Smrg	4	CARD32			drmMajor
733452262e1Smrg	4	CARD32			drmMinor
734452262e1Smrg└───
735452262e1Smrg
736635a5eb8Smrg┌───
737635a5eb8Smrg    DRI3ImportSyncobj
738635a5eb8Smrg	1	CARD8			major opcode
739635a5eb8Smrg	1	11			DRI3 opcode
740635a5eb8Smrg	2	3			length
741635a5eb8Smrg	4	SYNCOBJ			syncobj
742635a5eb8Smrg	4	Drawable		drawable
743635a5eb8Smrg	0	FD			syncobj fd
744635a5eb8Smrg└───
745635a5eb8Smrg
746635a5eb8Smrg┌───
747635a5eb8Smrg    DRI3FreeSyncobj
748635a5eb8Smrg	1	CARD8			major opcode
749635a5eb8Smrg	1	12			DRI3 opcode
750635a5eb8Smrg	2	2			length
751635a5eb8Smrg	4	SYNCOBJ			syncobj
752635a5eb8Smrg└───
753635a5eb8Smrg
75417ca54c3SmrgA.3 Protocol Events
75517ca54c3Smrg
75617ca54c3SmrgThe DRI3 extension defines no events.
75717ca54c3Smrg
75817ca54c3SmrgA.4 Protocol Errors
75917ca54c3Smrg
76017ca54c3SmrgThe DRI3 extension defines no errors.
76117ca54c3Smrg
76217ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
763