dri3proto.txt revision 17ca54c3
117ca54c3Smrg			  The DRI3 Extension
217ca54c3Smrg			     Version 1.2
317ca54c3Smrg			      2018-02-28
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>
3717ca54c3Smrg
3817ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
3917ca54c3Smrg
4017ca54c3Smrg2. Data Types
4117ca54c3Smrg
4217ca54c3SmrgThe DRI3 extension uses the RandR extension Provider data type to
4317ca54c3Smrgselect among multiple GPUs on a single screen and the Sync extension
4417ca54c3Smrgfence object to provide graphics object synchronization.
4517ca54c3Smrg
4617ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
4717ca54c3Smrg
4817ca54c3Smrg4. Errors
4917ca54c3Smrg
5017ca54c3SmrgDRI3 defines no errors.
5117ca54c3Smrg
5217ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
5317ca54c3Smrg
5417ca54c3Smrg5. Events
5517ca54c3Smrg
5617ca54c3SmrgDRI3 defines no events.
5717ca54c3Smrg
5817ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
5917ca54c3Smrg
6017ca54c3Smrg6. Protocol Types
6117ca54c3Smrg
6217ca54c3SmrgDRI3 defines no new protocol types.
6317ca54c3Smrg
6417ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
6517ca54c3Smrg
6617ca54c3Smrg7. Extension Initialization
6717ca54c3Smrg
6817ca54c3SmrgThe name of this extension is "DRI3"
6917ca54c3Smrg
7017ca54c3Smrg┌───
7117ca54c3Smrg    DRI3QueryVersion
7217ca54c3Smrg	client-major-version:	CARD32
7317ca54c3Smrg	client-minor-version:	CARD32
7417ca54c3Smrg7517ca54c3Smrg	major-version:		CARD32
7617ca54c3Smrg	minor-version:		CARD32
7717ca54c3Smrg└───
7817ca54c3Smrg
7917ca54c3Smrg	The client sends the highest supported version to the server
8017ca54c3Smrg	and the server sends the highest version it supports, but no
8117ca54c3Smrg	higher than the requested version. Major versions changes can
8217ca54c3Smrg	introduce incompatibilities in existing functionality, minor
8317ca54c3Smrg	version changes introduce only backward compatible changes.
8417ca54c3Smrg	It is the clients responsibility to ensure that the server
8517ca54c3Smrg	supports a version which is compatible with its expectations.
8617ca54c3Smrg
8717ca54c3Smrg	Backwards compatible changes included addition of new
8817ca54c3Smrg	requests.
8917ca54c3Smrg
9017ca54c3Smrg
9117ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄ 
9217ca54c3Smrg
9317ca54c3Smrg8. Extension Requests
9417ca54c3Smrg
9517ca54c3Smrg┌───
9617ca54c3Smrg    DRI3Open
9717ca54c3Smrg	drawable: DRAWABLE
9817ca54c3Smrg	provider: PROVIDER
9917ca54c3Smrg10017ca54c3Smrg	nfd: CARD8
10117ca54c3Smrg	device: FD
10217ca54c3Smrg└───
10317ca54c3Smrg	Errors: Drawable, Value, Match
10417ca54c3Smrg
10517ca54c3Smrg	This requests that the X server open the direct rendering
10617ca54c3Smrg	device associated with drawable and RandR provider. The
10717ca54c3Smrg	provider must support SourceOutput or SourceOffload.
10817ca54c3Smrg
10917ca54c3Smrg	The file descriptor for the device is returned in
11017ca54c3Smrg	'device'. 'nfd' will be set to one (this is strictly a
11117ca54c3Smrg	convenience for XCB which otherwise would need
11217ca54c3Smrg	request-specific information about how many file descriptors
11317ca54c3Smrg	were associated with this reply).
11417ca54c3Smrg
11517ca54c3Smrg┌───
11617ca54c3Smrg    DRI3PixmapFromBuffer
11717ca54c3Smrg	pixmap: PIXMAP
11817ca54c3Smrg	drawable: DRAWABLE
11917ca54c3Smrg	size: CARD32
12017ca54c3Smrg	width, height, stride: CARD16
12117ca54c3Smrg	depth, bpp: CARD8
12217ca54c3Smrg	buffer: FD
12317ca54c3Smrg└───
12417ca54c3Smrg	Errors: Alloc, Drawable, IDChoice, Value, Match
12517ca54c3Smrg
12617ca54c3Smrg	Creates a pixmap for the direct rendering object associated
12717ca54c3Smrg	with 'buffer' and the screen associated with 'drawable'.
12817ca54c3Smrg	Changes to pixmap will be visible in that direct rendered
12917ca54c3Smrg	object and changes to the direct rendered object will be
13017ca54c3Smrg	visible in the pixmap.
13117ca54c3Smrg
13217ca54c3Smrg	'size' specifies the total size of the buffer bytes. 'width',
13317ca54c3Smrg	'height' describe the geometry (in pixels) of the underlying
13417ca54c3Smrg	buffer. 'stride' specifies the number of bytes per scanline in
13517ca54c3Smrg	the buffer. The pixels within the buffer are not required to
13617ca54c3Smrg	be arranged in a simple linear fashion, but 'size' will be at
13717ca54c3Smrg	least 'height' * 'stride'.
13817ca54c3Smrg
13917ca54c3Smrg	Precisely how any additional information about the buffer is
14017ca54c3Smrg	shared is outside the scope of this extension.
14117ca54c3Smrg
14217ca54c3Smrg	If buffer cannot be used with the screen associated with
14317ca54c3Smrg	drawable, a Match error is returned.
14417ca54c3Smrg
14517ca54c3Smrg	If depth or bpp are not supported by the screen, a Value error
14617ca54c3Smrg	is returned.
14717ca54c3Smrg
14817ca54c3Smrg	For information on synchronization of buffer access between
14917ca54c3Smrg	the client and the X server, please see section 12.
15017ca54c3Smrg
15117ca54c3Smrg┌───
15217ca54c3Smrg    DRI3BufferFromPixmap
15317ca54c3Smrg	pixmap: PIXMAP
15417ca54c3Smrg15517ca54c3Smrg	nfd: CARD8
15617ca54c3Smrg	size: CARD32
15717ca54c3Smrg	width, height, stride: CARD16
15817ca54c3Smrg	depth, bpp: CARD8
15917ca54c3Smrg	buffer: FD
16017ca54c3Smrg└───
16117ca54c3Smrg	Errors: Pixmap, Match
16217ca54c3Smrg
16317ca54c3Smrg	Pass back a direct rendering object associated with
16417ca54c3Smrg	pixmap. Changes to pixmap will be visible in that
16517ca54c3Smrg	direct rendered object and changes to the direct rendered
16617ca54c3Smrg	object will be visible in the pixmap.
16717ca54c3Smrg
16817ca54c3Smrg	'size' specifies the total size of the buffer bytes. 'width',
16917ca54c3Smrg	'height' describe the geometry (in pixels) of the underlying
17017ca54c3Smrg	buffer. 'stride' specifies the number of bytes per scanline in
17117ca54c3Smrg	the buffer. The pixels within the buffer are not required to
17217ca54c3Smrg	be arranged in a simple linear fashion, but 'size' will be at
17317ca54c3Smrg	least 'height' * 'stride'.
17417ca54c3Smrg
17517ca54c3Smrg	Precisely how any additional information about the buffer is
17617ca54c3Smrg	shared is outside the scope of this extension.
17717ca54c3Smrg
17817ca54c3Smrg	If buffer cannot be used with the screen associated with
17917ca54c3Smrg	drawable, a Match error is returned.
18017ca54c3Smrg
18117ca54c3Smrg	For information on synchronization of buffer access between
18217ca54c3Smrg	the client and the X server, please see section 12.
18317ca54c3Smrg
18417ca54c3Smrg┌───
18517ca54c3Smrg    DRI3FenceFromFD
18617ca54c3Smrg	drawable: DRAWABLE
18717ca54c3Smrg	fence: FENCE
18817ca54c3Smrg	initially-triggered: BOOL
18917ca54c3Smrg	fd: FD
19017ca54c3Smrg└───
19117ca54c3Smrg	Errors: IDchoice, Drawable
19217ca54c3Smrg
19317ca54c3Smrg	Creates a Sync extension Fence that provides the regular Sync
19417ca54c3Smrg	extension semantics along with a file descriptor that provides
19517ca54c3Smrg	a device-specific mechanism to manipulate the fence directly.
19617ca54c3Smrg	Details about the mechanism used with this file descriptor are
19717ca54c3Smrg	outside the scope of the DRI3 extension.
19817ca54c3Smrg
19917ca54c3Smrg	For information on synchronization of buffer access between
20017ca54c3Smrg	the client and the X server, please see section 12.
20117ca54c3Smrg
20217ca54c3Smrg┌───
20317ca54c3Smrg    DRI3FDFromFence
20417ca54c3Smrg	drawable: DRAWABLE
20517ca54c3Smrg	fence: FENCE
20617ca54c3Smrg20717ca54c3Smrg	fd: FD
20817ca54c3Smrg└───
20917ca54c3Smrg	Errors: IDchoice, Drawable, Match
21017ca54c3Smrg
21117ca54c3Smrg	Given a Sync extension Fence that provides the regular Sync
21217ca54c3Smrg	extension semantics, returns a file descriptor that provides a
21317ca54c3Smrg	device-specific mechanism to manipulate the fence directly.
21417ca54c3Smrg	Details about the mechanism used with this file descriptor are
21517ca54c3Smrg	outside the scope of the DRI3 extension. 'drawable' must be
21617ca54c3Smrg	associated with a direct rendering device that 'fence' can
21717ca54c3Smrg	work with, otherwise a Match error results.
21817ca54c3Smrg
21917ca54c3Smrg	For information on synchronization of buffer access between
22017ca54c3Smrg	the client and the X server, please see section 12.
22117ca54c3Smrg
22217ca54c3Smrg┌───
22317ca54c3Smrg    DRI3GetSupportedModifiers
22417ca54c3Smrg	window: WINDOW
22517ca54c3Smrg	depth: CARD8
22617ca54c3Smrg	bpp: CARD8
22717ca54c3Smrg22817ca54c3Smrg	num_window_modifiers: CARD32
22917ca54c3Smrg	num_screen_modifiers: CARD32
23017ca54c3Smrg	window_modifiers: ListOfCARD64
23117ca54c3Smrg	screen_modifiers: ListOfCARD64
23217ca54c3Smrg└───
23317ca54c3Smrg	Errors: Window, Match
23417ca54c3Smrg
23517ca54c3Smrg	Return supported DRM FourCC modifiers for the specified
23617ca54c3Smrg	'window'.
23717ca54c3Smrg
23817ca54c3Smrg	The first list of 'window_modifiers' contains a set of
23917ca54c3Smrg	modifiers which the server considers optimal for the window's
24017ca54c3Smrg	current configuration. Using these modifiers to allocate, even
24117ca54c3Smrg	if locally suboptimal to the client driver, may result in a
24217ca54c3Smrg	more optimal display pipeline, e.g. by avoiding composition.
24317ca54c3Smrg
24417ca54c3Smrg	The second list of 'screen_modifiers', is the total set of
24517ca54c3Smrg	modifiers which are acceptable for use on the Screen associated
24617ca54c3Smrg	with 'window'. This set of modifiers will not change over the
24717ca54c3Smrg	lifetime of the client. Using this set of modifiers to allocate
24817ca54c3Smrg	may not result in a globally optimal pipeline, if separate
24917ca54c3Smrg	'window_modifiers' are available.
25017ca54c3Smrg
25117ca54c3Smrg	It is expected that a client calling this request will obtain
25217ca54c3Smrg	the modifiers for a particular window, allocate buffers using
25317ca54c3Smrg	the preferred modifier set as described above, create a Pixmap
25417ca54c3Smrg	referring to the storage of those buffers using the
25517ca54c3Smrg	DRI3BuffersFromPixmap request, then make the content visible
25617ca54c3Smrg	in the storage of those buffers visible with a request such as
25717ca54c3Smrg	the Present extension's PresentPixmap.
25817ca54c3Smrg
25917ca54c3Smrg	The meaning of any modifier is canonically defined in
26017ca54c3Smrg	drm_fourcc.h.
26117ca54c3Smrg
26217ca54c3Smrg┌───
26317ca54c3Smrg    DRI3PixmapFromBuffers
26417ca54c3Smrg	pixmap: PIXMAP
26517ca54c3Smrg	window: WINDOW
26617ca54c3Smrg	num_buffers: CARD8
26717ca54c3Smrg	width, height: CARD16
26817ca54c3Smrg	stride0, offset0: CARD32
26917ca54c3Smrg	stride1, offset1: CARD32
27017ca54c3Smrg	stride2, offset2: CARD32
27117ca54c3Smrg	stride3, offset3: CARD32
27217ca54c3Smrg	depth, bpp: CARD8
27317ca54c3Smrg	modifier: CARD64
27417ca54c3Smrg	buffers: ListOfFD
27517ca54c3Smrg└───
27617ca54c3Smrg	Errors: Alloc, Window, IDChoice, Value, Match
27717ca54c3Smrg
27817ca54c3Smrg	Creates a pixmap for the direct rendering object associated
27917ca54c3Smrg	with 'buffers' and the screen associated with 'window'.
28017ca54c3Smrg	Changes to pixmap will be visible in that direct rendered
28117ca54c3Smrg	object and changes to the direct rendered object will be
28217ca54c3Smrg	visible in the pixmap. The pixmap will be available for
28317ca54c3Smrg	presentation to the window.
28417ca54c3Smrg
28517ca54c3Smrg	In contrast to PixmapFromBuffer, multiple buffers may be
28617ca54c3Smrg	combined to specify a single logical source for pixel
28717ca54c3Smrg	sampling: 'num_buffers' may be set from 1 (single buffer,
28817ca54c3Smrg	akin to PixmapFromBuffer) to 4. This is the number of file
28917ca54c3Smrg	descriptors which will be sent with this request; one per
29017ca54c3Smrg	buffer.
29117ca54c3Smrg
29217ca54c3Smrg	Modifiers allow explicit specification of non-linear sources,
29317ca54c3Smrg	such as tiled or compressed buffers. The combination of bpp,
29417ca54c3Smrg	depth, and modifier allows unambiguous declaration of the
29517ca54c3Smrg	buffer layout in a manner defined by the DRM tokens.
29617ca54c3Smrg
29717ca54c3Smrg	If 'modifier' is DRM_FORMAT_MOD_INVALID, the client does
29817ca54c3Smrg	not have information on the buffer layout. In this case, the
29917ca54c3Smrg	buffer may only have a single plane. The driver may make its
30017ca54c3Smrg	own inference through unspecified means to determine the exact
30117ca54c3Smrg	buffer layout, however this is neither required nor defined
30217ca54c3Smrg	by the specification, and is considered an implementation
30317ca54c3Smrg	detail of the particular driver.
30417ca54c3Smrg
30517ca54c3Smrg	'width' and 'height' describe the geometry (in pixels) of the
30617ca54c3Smrg	logical pixel-sample source.
30717ca54c3Smrg
30817ca54c3Smrg	'strideN' and 'offsetN' define the number of bytes per logical
30917ca54c3Smrg	scanline, and the distance in bytes from the beginning of the
31017ca54c3Smrg	buffer passed for that plane until the start of the sample
31117ca54c3Smrg	source for that plane, respectively for plane N. If the plane
31217ca54c3Smrg	is not used according to the format and modifier specification,
31317ca54c3Smrg	both values for that plane must be zero.
31417ca54c3Smrg
31517ca54c3Smrg	Precisely how any additional information about the buffer (such
31617ca54c3Smrg	as memory placement) is shared is outside the scope of this
31717ca54c3Smrg	extension.
31817ca54c3Smrg
31917ca54c3Smrg	If the buffer(s) cannot be used with the screen associated with
32017ca54c3Smrg	'window', a Match error is returned.
32117ca54c3Smrg
32217ca54c3Smrg	If the bpp, depth, and modifier combination is not supported by
32317ca54c3Smrg	the screen, a Value error is returned.
32417ca54c3Smrg
32517ca54c3Smrg	For information on synchronization of buffer access between
32617ca54c3Smrg	the client and the X server, please see section 12.
32717ca54c3Smrg
32817ca54c3Smrg┌───
32917ca54c3Smrg    DRI3BuffersFromPixmap
33017ca54c3Smrg	pixmap: PIXMAP
33117ca54c3Smrg33217ca54c3Smrg	nfd: CARD8
33317ca54c3Smrg	width, height: CARD16
33417ca54c3Smrg	depth, bpp: CARD8
33517ca54c3Smrg	modifier: CARD64
33617ca54c3Smrg	strides: ListOfCARD32
33717ca54c3Smrg	offsets: ListOfCARD32
33817ca54c3Smrg	buffers: ListOfFD
33917ca54c3Smrg└───
34017ca54c3Smrg	Errors: Pixmap, Match
34117ca54c3Smrg
34217ca54c3Smrg	Returns direct rendering objects associated with 'pixmap'.
34317ca54c3Smrg	Changes to 'pixmap' will be visible in the direct rendered
34417ca54c3Smrg	objects and changes to the direct rendered objects will be
34517ca54c3Smrg	visible in 'pixmap' after flushing and synchronization.
34617ca54c3Smrg
34717ca54c3Smrg	'width' and 'height' describe the geometry (in pixels) of the
34817ca54c3Smrg	logical pixel-sample source from combining the direct rendering
34917ca54c3Smrg	objects.
35017ca54c3Smrg
35117ca54c3Smrg	See PixmapFromBuffers for more details on DRM modifiers usage.
35217ca54c3Smrg
35317ca54c3Smrg	'nfd' describes the number of buffers returned for the pixmap,
35417ca54c3Smrg	which must be combined together according to 'depth', 'bpp', and
35517ca54c3Smrg	'modifier'.
35617ca54c3Smrg
35717ca54c3Smrg	For each buffer, there is an entry in the 'strides',
35817ca54c3Smrg	'offsets', and 'buffers' list. 'buffer' contains a single file
35917ca54c3Smrg	descriptor referring to the buffer. 'stride' specifies the
36017ca54c3Smrg	number of bytes per logical scanline for this plane, and
36117ca54c3Smrg	'offset' specifies the distance in bytes from the beginning
36217ca54c3Smrg	of 'buffer' until the start of the sample source for that
36317ca54c3Smrg	plane.
36417ca54c3Smrg
36517ca54c3Smrg	Precisely how any additional information about the buffer is
36617ca54c3Smrg	shared is outside the scope of this extension.
36717ca54c3Smrg
36817ca54c3Smrg	If buffers cannot be exported from the the screen associated
36917ca54c3Smrg	with 'pixmap', a Match error is returned.
37017ca54c3Smrg
37117ca54c3Smrg	For information on synchronization of buffer access between
37217ca54c3Smrg	the client and the X server, please see section 12.
37317ca54c3Smrg
37417ca54c3Smrg
37517ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
37617ca54c3Smrg
37717ca54c3Smrg9. Extension Events
37817ca54c3Smrg
37917ca54c3SmrgDRI3 defines no events.
38017ca54c3Smrg
38117ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
38217ca54c3Smrg
38317ca54c3Smrg10. Extension Versioning
38417ca54c3Smrg
38517ca54c3SmrgThe DRI3 extension is adapted from the DRI2 extension.
38617ca54c3Smrg
38717ca54c3Smrg	1.0: First published version
38817ca54c3Smrg
38917ca54c3Smrg	1.1: Cosmetic changes
39017ca54c3Smrg
39117ca54c3Smrg	1.2: Add GetSupportedModifiers,
39217ca54c3Smrg	     PixmapFromBuffers, and BuffersFromPixmap requests.
39317ca54c3Smrg
39417ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
39517ca54c3Smrg
39617ca54c3Smrg
39717ca54c3Smrg11. Relationship with other extensions
39817ca54c3Smrg
39917ca54c3SmrgAs an extension designed to support other extensions, there is
40017ca54c3Smrgnaturally some interactions with other extensions.
40117ca54c3Smrg
40217ca54c3Smrg11.1 GLX
40317ca54c3Smrg
40417ca54c3SmrgGLX is both an application interface and an X extension. OpenGL
40517ca54c3Smrgapplications using the GLX API will use the GLX extension, DRI3 and
40617ca54c3SmrgPresent when doing direct rendering.
40717ca54c3Smrg
40817ca54c3Smrg11.2 Present
40917ca54c3Smrg
41017ca54c3SmrgThe Present extension provides a way to synchronize the display of pixmap
41117ca54c3Smrgcontents to the screen. When used in conjunction with DRI3, they
41217ca54c3Smrgprovide a complete direct rendering solution for OpenGL or other APIs.
41317ca54c3Smrg
41417ca54c3Smrg11.3 DRI2
41517ca54c3Smrg
41617ca54c3SmrgDRI3 provides similar functionality to the DRI2Connect and
41717ca54c3SmrgDRI2GetBuffersWithFormat requests, however DRI3 uses file descriptors
41817ca54c3Smrgto refer to the direct rendering device and buffers.
41917ca54c3Smrg
42017ca54c3SmrgPresent and DRI3 are designed in conjunction to replace DRI2
42117ca54c3Smrg
42217ca54c3Smrg11.2 XvMC / Xv
42317ca54c3Smrg
42417ca54c3SmrgIt might be nice to be able to reference YUV formatted direct rendered
42517ca54c3Smrgobjects from the X server.
42617ca54c3Smrg
42717ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
42817ca54c3Smrg
42917ca54c3Smrg12. Synchronization
43017ca54c3Smrg
43117ca54c3SmrgSynchronization of access to buffers shared between processes is not
43217ca54c3Smrgcurrently explicitly controlled by this protocol.
43317ca54c3Smrg
43417ca54c3SmrgWithout the use of additional extensions not defined by the DRI3
43517ca54c3Smrgprotocol as of version 1.2, synchronization between multiple
43617ca54c3Smrgprocesses and contexts is considered to follow the implicit model.
43717ca54c3Smrg
43817ca54c3SmrgIn this model, the driver is required to have a global view of
43917ca54c3Smrgaccess requests issued by all processes with a reference to the
44017ca54c3Smrgbuffer, and control scheduling of all operations on that buffer,
44117ca54c3Smrgwhether performed by the CPU or auxiliary hardware.
44217ca54c3Smrg
44317ca54c3SmrgThe driver is responsible for enforcing a strict ordering to protect
44417ca54c3Smrgagainst write-after-read or read-after-write hazards, such that any
44517ca54c3Smrgreads requested by one process or context, are fulfilled before any
44617ca54c3Smrgwrites requested by another process or context, as long as that read
44717ca54c3Smrgwas definitively submitted before the write.
44817ca54c3Smrg
44917ca54c3SmrgA similar dependency exists for reads submitted after writes: the
45017ca54c3Smrgdriver must ensure that the write is fully visible and coherent to
45117ca54c3Smrgthe read request.
45217ca54c3Smrg
45317ca54c3SmrgAs a purely illustrative example, if two processes share a buffer,
45417ca54c3Smrgwhere one process reads from a buffer using an OpenGL texture
45517ca54c3Smrgsampler and submits this work by calling 'glFlush', and the other
45617ca54c3Smrgprocess submits work to the driver to write to that buffer, the
45717ca54c3Smrgdriver is responsible for ensuring that the results of the latter
45817ca54c3Smrgwrite are not visible to the texture sampler.
45917ca54c3Smrg
46017ca54c3SmrgThe Sync fences provided by DRI3 control only this submission of
46117ca54c3Smrgwork and ensuing global visibility of the requests, rather than the
46217ca54c3Smrgcompletion of the work within any hardware. To further the example
46317ca54c3Smrgabove, a fence used to prevent any writes to the buffer before the
46417ca54c3Smrgsampler had completed access, the fence would be signaled when
46517ca54c3Smrg'glFlush' had been called, at which point the request has become
46617ca54c3Smrgglobally visible to the driver's request-scheduling and
46717ca54c3Smrgsynchronization mechanisms. The logical ordering of requests made
46817ca54c3Smrgby software has been preserved, and the driver then takes care
46917ca54c3Smrgto ensure that these requests are scheduled such they do not
47017ca54c3Smrgobserve effects from requests made later in time.
47117ca54c3Smrg
47217ca54c3SmrgThis presents a fully coherent in-order FIFO-like model across
47317ca54c3Smrgprocesses, where synchronzation is handled externally to the DRI3
47417ca54c3Smrgclient with no explicit intervention.
47517ca54c3Smrg
47617ca54c3SmrgThis restriction also applies for cross-device usage.
47717ca54c3Smrg
47817ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
47917ca54c3Smrg
48017ca54c3SmrgAppendix A. Protocol Encoding
48117ca54c3Smrg
48217ca54c3SmrgSyntactic Conventions
48317ca54c3Smrg
48417ca54c3SmrgThis document uses the same syntactic conventions as the core X
48517ca54c3Smrgprotocol encoding document.
48617ca54c3Smrg
48717ca54c3Smrg
48817ca54c3SmrgA.1 Common Types
48917ca54c3Smrg
49017ca54c3SmrgNone.
49117ca54c3Smrg
49217ca54c3SmrgA.2 Protocol Requests
49317ca54c3Smrg
49417ca54c3Smrg┌───
49517ca54c3Smrg    DRI3QueryVersion
49617ca54c3Smrg	1	CARD8			major opcode
49717ca54c3Smrg	1	0			DRI3 opcode
49817ca54c3Smrg	2	3			length
49917ca54c3Smrg	4	CARD32			major version
50017ca54c3Smrg	4	CARD32			minor version
50117ca54c3Smrg50217ca54c3Smrg	1	1			Reply
50317ca54c3Smrg        1				unused
50417ca54c3Smrg	2	CARD16			sequence number
50517ca54c3Smrg	4	0			reply length
50617ca54c3Smrg	4	CARD32			major version
50717ca54c3Smrg        4	CARD32			minor version
50817ca54c3Smrg	16				unused	
50917ca54c3Smrg└───
51017ca54c3Smrg
51117ca54c3Smrg
51217ca54c3Smrg┌───
51317ca54c3Smrg    DRI3Open
51417ca54c3Smrg	1	CARD8			major opcode
51517ca54c3Smrg	1	1			DRI3 opcode
51617ca54c3Smrg	2	4			length
51717ca54c3Smrg	4	DRAWABLE		drawable
51817ca54c3Smrg	4	PROVIDER		provider
51917ca54c3Smrg52017ca54c3Smrg	1	1			Reply
52117ca54c3Smrg        1	1			nfd
52217ca54c3Smrg	2	CARD16			sequence number
52317ca54c3Smrg	4	0			reply length
52417ca54c3Smrg	24				unused
52517ca54c3Smrg
52617ca54c3Smrg	0	FD			device
52717ca54c3Smrg└───
52817ca54c3Smrg
52917ca54c3Smrg┌───
53017ca54c3Smrg    DRI3PixmapFromBuffer
53117ca54c3Smrg	1	CARD8			major opcode
53217ca54c3Smrg	1	2			DRI3 opcode
53317ca54c3Smrg	2	6			length
53417ca54c3Smrg	4	Pixmap			pixmap
53517ca54c3Smrg	4	Drawable		drawable
53617ca54c3Smrg	4	CARD32			size
53717ca54c3Smrg	2	CARD16			width
53817ca54c3Smrg	2	CARD16			height
53917ca54c3Smrg	2	CARD16			stride
54017ca54c3Smrg	1	CARD8			depth
54117ca54c3Smrg	1	CARD8			bpp
54217ca54c3Smrg
54317ca54c3Smrg	0	FD			buffer
54417ca54c3Smrg└───
54517ca54c3Smrg
54617ca54c3Smrg┌───
54717ca54c3Smrg    DRI3BufferFromPixmap
54817ca54c3Smrg	1	CARD8			major opcode
54917ca54c3Smrg	1	3			DRI3 opcode
55017ca54c3Smrg	2	2			length
55117ca54c3Smrg	4	Pixmap			pixmap
55217ca54c3Smrg55317ca54c3Smrg	1	1			Reply
55417ca54c3Smrg        1	1			nfd
55517ca54c3Smrg	2	CARD16			sequence number
55617ca54c3Smrg	4	0			reply length
55717ca54c3Smrg	4	CARD32			size
55817ca54c3Smrg	2	CARD16			width
55917ca54c3Smrg	2	CARD16			height
56017ca54c3Smrg	2	CARD16			stride
56117ca54c3Smrg	1	CARD8			depth
56217ca54c3Smrg	1	CARD8			bpp
56317ca54c3Smrg	12				unused
56417ca54c3Smrg
56517ca54c3Smrg	0	FD			buffer
56617ca54c3Smrg└───
56717ca54c3Smrg
56817ca54c3Smrg┌───
56917ca54c3Smrg    DRI3FenceFromFD
57017ca54c3Smrg	1	CARD8			major opcode
57117ca54c3Smrg	1	4			DRI3 opcode
57217ca54c3Smrg	2	4			length
57317ca54c3Smrg	4	Drawable		drawable
57417ca54c3Smrg	4	Fence			fence
57517ca54c3Smrg	1	BOOL			initially triggered
57617ca54c3Smrg	3				unused
57717ca54c3Smrg
57817ca54c3Smrg	0	FD			fence fd
57917ca54c3Smrg└───
58017ca54c3Smrg
58117ca54c3Smrg┌───
58217ca54c3Smrg    DRI3FDFromFence
58317ca54c3Smrg	1	CARD8			major opcode
58417ca54c3Smrg	1	5			DRI3 opcode
58517ca54c3Smrg	2	3			length
58617ca54c3Smrg	4	Drawable		drawable
58717ca54c3Smrg	4	Fence			fence
58817ca54c3Smrg58917ca54c3Smrg	1	1			Reply
59017ca54c3Smrg        1	1			nfd
59117ca54c3Smrg	2	CARD16			sequence number
59217ca54c3Smrg	4	0			reply length
59317ca54c3Smrg	24				unused
59417ca54c3Smrg
59517ca54c3Smrg	0	FD			fence fd
59617ca54c3Smrg└───
59717ca54c3Smrg
59817ca54c3Smrg┌───
59917ca54c3Smrg    DRI3GetSupportedModifiers
60017ca54c3Smrg	1	CARD8			major opcode
60117ca54c3Smrg	1	7			DRI3 opcode
60217ca54c3Smrg	2	3			length
60317ca54c3Smrg	4	Window			window
60417ca54c3Smrg	1	CARD8			depth
60517ca54c3Smrg	1	CARD8			bpp
60617ca54c3Smrg	2				unused
60717ca54c3Smrg60817ca54c3Smrg	1	1			Reply
60917ca54c3Smrg        1	0			unused
61017ca54c3Smrg	2	CARD16			sequence number
61117ca54c3Smrg	4	CARD32			reply length
61217ca54c3Smrg	4	CARD32			num_window_modifiers
61317ca54c3Smrg	4	CARD32			num_screen_modifiers
61417ca54c3Smrg	16				unused
61517ca54c3Smrg
61617ca54c3Smrg	4	ListOfCARD64		window_modifiers[num_window_modifiers]
61717ca54c3Smrg	4	ListOfCARD64		screen_modifiers[num_screen_modifiers]
61817ca54c3Smrg└───
61917ca54c3Smrg
62017ca54c3Smrg┌───
62117ca54c3Smrg    DRI3PixmapFromBuffers
62217ca54c3Smrg	1	CARD8			major opcode
62317ca54c3Smrg	1	8			DRI3 opcode
62417ca54c3Smrg	2	8			length
62517ca54c3Smrg	4	Pixmap			pixmap
62617ca54c3Smrg	4	Window			window
62717ca54c3Smrg	1	CARD8			num_buffers
62817ca54c3Smrg	3				unused
62917ca54c3Smrg	2	CARD16			width
63017ca54c3Smrg	2	CARD16			height
63117ca54c3Smrg	4	CARD32			stride0
63217ca54c3Smrg	4	CARD32			offset0
63317ca54c3Smrg	4	CARD32			stride1
63417ca54c3Smrg	4	CARD32			offset1
63517ca54c3Smrg	4	CARD32			stride2
63617ca54c3Smrg	4	CARD32			offset2
63717ca54c3Smrg	4	CARD32			stride3
63817ca54c3Smrg	4	CARD32			offset3
63917ca54c3Smrg	1	CARD8			depth
64017ca54c3Smrg	1	CARD8			bpp
64117ca54c3Smrg	2				unused
64217ca54c3Smrg	8	CARD64			modifier
64317ca54c3Smrg
64417ca54c3Smrg	0	ListOfFD		buffers[num_buffers]
64517ca54c3Smrg└───
64617ca54c3Smrg
64717ca54c3Smrg┌───
64817ca54c3Smrg    DRI3BuffersFromPixmap
64917ca54c3Smrg	1	CARD8			major opcode
65017ca54c3Smrg	1	9			DRI3 opcode
65117ca54c3Smrg	2	2			length
65217ca54c3Smrg	4	Pixmap			pixmap
65317ca54c3Smrg65417ca54c3Smrg	1	1			Reply
65517ca54c3Smrg        1	CARD8			nfd
65617ca54c3Smrg	2	CARD16			sequence number
65717ca54c3Smrg	4	CARD32			reply length
65817ca54c3Smrg	2	CARD16			width
65917ca54c3Smrg	2	CARD16			height
66017ca54c3Smrg	4	CARD8			unused
66117ca54c3Smrg	8	CARD64			modifier
66217ca54c3Smrg	1	CARD8			depth
66317ca54c3Smrg	1	CARD8			bpp
66417ca54c3Smrg	6				unused
66517ca54c3Smrg
66617ca54c3Smrg	0	ListOfFD		buffer[nfd]
66717ca54c3Smrg	4	ListOfCARD32		strides[nfd]
66817ca54c3Smrg	4	ListOfCARD32		offsets[nfd]
66917ca54c3Smrg└───
67017ca54c3Smrg
67117ca54c3SmrgA.3 Protocol Events
67217ca54c3Smrg
67317ca54c3SmrgThe DRI3 extension defines no events.
67417ca54c3Smrg
67517ca54c3SmrgA.4 Protocol Errors
67617ca54c3Smrg
67717ca54c3SmrgThe DRI3 extension defines no errors.
67817ca54c3Smrg
67917ca54c3Smrg			     ❄ ❄ ❄  ❄  ❄ ❄ ❄
680