117ca54c3Smrg			  The DRI2 Extension
217ca54c3Smrg			      Version 2.0
317ca54c3Smrg			      2008-09-04
417ca54c3Smrg      
517ca54c3Smrg			  Kristian Høgsberg
617ca54c3Smrg			    krh@redhat.com
717ca54c3Smrg			     Red Hat, Inc
817ca54c3Smrg
917ca54c3Smrg
1017ca54c3Smrg1. Introduction
1117ca54c3Smrg
1217ca54c3SmrgThe DRI2 extension is designed to associate and access auxiliary
1317ca54c3Smrgrendering buffers with an X drawable.
1417ca54c3Smrg
1517ca54c3SmrgDRI2 is a essentially a helper extension to support implementation of
1617ca54c3Smrgdirect rendering drivers/libraries/technologies.
1717ca54c3Smrg
1817ca54c3SmrgThe main consumer of this extension will be a direct rendering OpenGL
1917ca54c3Smrgdriver, but the DRI2 extension is not designed to be OpenGL specific.
2017ca54c3SmrgDirect rendering implementations of OpenVG, Xv, cairo and other
2117ca54c3Smrggraphics APIs should find the functionality exposed by this extension
2217ca54c3Smrghelpful and hopefully sufficient.
2317ca54c3Smrg
2417ca54c3SmrgRelation to XF86DRI
2517ca54c3Smrg
2617ca54c3Smrg
2717ca54c3Smrg1.1. Acknowledgements
2817ca54c3Smrg
2917ca54c3SmrgKevin E. Martin <kem@redhat.com>
3017ca54c3SmrgKeith Packard <keithp@keithp.com>
3117ca54c3SmrgEric Anholt <eric@anholt.net>
3217ca54c3SmrgKeith Whitwell <keith@tungstengraphics.com>
3317ca54c3SmrgJerome Glisse <glisse@freedesktop.org>
3417ca54c3SmrgIan Romanick <ian.d.romanick@intel.com>
3517ca54c3SmrgMichel Dänzer <michel@tungstengraphics.com>
3617ca54c3SmrgJesse Barnes <jbarnes@virtuousgeek.org>
3717ca54c3Smrg
3817ca54c3Smrg
3917ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
4017ca54c3Smrg
4117ca54c3Smrg
4217ca54c3Smrg2. DRI2 Concepts
4317ca54c3Smrg
4417ca54c3Smrg
4517ca54c3Smrg2.1. Attachment points
4617ca54c3Smrg
4717ca54c3SmrgStolen from OpenGL FBOs, I guess.
4817ca54c3Smrg
4917ca54c3Smrg
5017ca54c3Smrg2.2. Kernel rendering manager
5117ca54c3Smrg
5217ca54c3SmrgThis specification assumes a rendering architecture, where an
5317ca54c3Smrgunderlying kernel rendering manager that can provide 32 bit integer
5417ca54c3Smrghandles to video memory buffers.  These handles can be passed between
5517ca54c3Smrgprocesses, which, through a direct rendering driver, submit rendering
5617ca54c3Smrgto the kernel rendering manager, targeting and/or sourcing from these
5717ca54c3Smrgbuffers.  This extension provides a means to communicate about such
5817ca54c3Smrgbuffers as associated with an X drawable.
5917ca54c3Smrg
6017ca54c3SmrgThe details of how the direct rendering driver use the buffer names
6117ca54c3Smrgand submit the rendering requests is outside the scope of this
6217ca54c3Smrgspecification.  However, Appendix B does discuss implementation of
6317ca54c3Smrgthis specification on the Graphics Execution Manager (GEM).
6417ca54c3Smrg
6517ca54c3Smrg
6617ca54c3Smrg2.3. Request ordering
6717ca54c3Smrg
6817ca54c3SmrgNo ordering between swap buffers and X rendering.  X rendering to src
6917ca54c3Smrgbuffers will block if they have a vblank pending.
7017ca54c3Smrg
7117ca54c3Smrg
7217ca54c3Smrg2.4 Authentication model
7317ca54c3Smrg
7417ca54c3SmrgThe purpose of the DRM authentication scheme is to grant access to the
7517ca54c3Smrgkernel rendering manager buffers created by the X server if, and only
7617ca54c3Smrgif, the client has access to the X server.  This is achieved in a
7717ca54c3Smrgthree-step protocol:
7817ca54c3Smrg
7917ca54c3Smrg	1) The client gets a token from the kernel rendering manager
8017ca54c3Smrg	that uniquely identifies it.  The token is a 32 bit integer.
8117ca54c3Smrg
8217ca54c3Smrg	2) The client passes the token to the X server in the
8317ca54c3Smrg	DRI2Authenticate request.  This request is a round trip to
8417ca54c3Smrg	make sure the X server has received and processed the
8517ca54c3Smrg	authentication before the client starts accessing the DRM.
8617ca54c3Smrg
8717ca54c3Smrg	3) The X server authorizes the client by passing the token to
8817ca54c3Smrg	the kernel rendering manager.
8917ca54c3Smrg
9017ca54c3SmrgA kernel rendering manager can choose not to implement any
9117ca54c3Smrgauthentication and just allow access to all buffers.
9217ca54c3Smrg
9317ca54c3Smrg
9417ca54c3Smrg2.5 Rendering to the X front buffer
9517ca54c3Smrg
9617ca54c3SmrgOpenGL allows the client to render to the front buffer, either by
9717ca54c3Smrgusing a single-buffered configuration or but explicitly setting the
9817ca54c3Smrgdraw buffer to GL_FRONT_LEFT.  Not allowed!
9917ca54c3Smrg
10017ca54c3SmrgThe client must ask for a fake front buffer, render to that and then
10117ca54c3Smrguse DRI2CopyRegion to copy contents back and forth between the fake
10217ca54c3Smrgfront buffer and the real front buffer.  When X and direct rendering
10317ca54c3Smrgto a front buffer is interleaved, it is the responsibility of the
10417ca54c3Smrgapplication to synchronize access using glXWaitGL and glXWaitX.  A
10517ca54c3SmrgDRI2 implementation of direct rendering GLX, should use these entry
10617ca54c3Smrgpoints to copy contents back and forth to as necessary to ensure
10717ca54c3Smrgconsistent rendering.
10817ca54c3Smrg
10917ca54c3SmrgThe client may also use the DRI2SwapBuffers function to request a swap
11017ca54c3Smrgof the front and back buffers.  If the display server supports it, this
11117ca54c3Smrgoperation may be preferred, since it may be easier and/or more performant
11217ca54c3Smrgfor the server to perform a simple buffer swap rather than a blit.
11317ca54c3Smrg
11417ca54c3Smrg2.6 Synchronizing rendering
11517ca54c3Smrg
11617ca54c3SmrgDRI2 provides several methods for synchronizing drawing with various events.
11717ca54c3SmrgThe protocol for these methods is based on the SGI_video_sync and
11817ca54c3SmrgOML_sync_control GLX extensions.  Using the DRI2WaitMSC request, a client
11917ca54c3Smrgcan wait for a specific frame count or divisor/remainder before continuing
12017ca54c3Smrgits processing.  With the DRI2WaitSBC request, clients can block until a given
12117ca54c3Smrgswap count is reached (as incremented by DRI2SwapBuffers).  Finally, using
12217ca54c3SmrgDRI2SwapBuffers, clients can limit their frame rate by specifying a swap
12317ca54c3Smrginterval using the swap interval call (currently only available through GLX)
12417ca54c3Smrgor by using the OML swap buffers routine.
12517ca54c3Smrg
12617ca54c3Smrg2.7 Events
12717ca54c3Smrg
12817ca54c3SmrgDRI2 provides an event to indicate when a DRI2SwapBuffers request has
12917ca54c3Smrgbeen completed.  This can be used to throttle drawing on the client
13017ca54c3Smrgside and tie into application main loops.
13117ca54c3Smrg
13217ca54c3SmrgAnother event is generated when the validity of the requested buffers
13317ca54c3Smrgchanges.
13417ca54c3Smrg
13517ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
13617ca54c3Smrg
13717ca54c3Smrg
13817ca54c3Smrg3. Data Types
13917ca54c3Smrg
14017ca54c3SmrgThe server side region support specified in the Xfixes extension
14117ca54c3Smrgversion 2 is used in the CopyRegion request.
14217ca54c3Smrg
14317ca54c3Smrg
14417ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
14517ca54c3Smrg
14617ca54c3Smrg
14717ca54c3Smrg4. Errors
14817ca54c3Smrg
14917ca54c3SmrgNo errors are defined by the DRI2 extension.
15017ca54c3Smrg
15117ca54c3Smrg
15217ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
15317ca54c3Smrg
15417ca54c3Smrg5. Events
15517ca54c3Smrg
15617ca54c3SmrgThe only events provided by DRI2 are DRI2_BufferSwapComplete
15717ca54c3Smrgand DRI2InvalidateBuffers.
15817ca54c3Smrg
15917ca54c3Smrg
16017ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
16117ca54c3Smrg
16217ca54c3Smrg
16317ca54c3Smrg6. Protocol Types
16417ca54c3Smrg
16517ca54c3SmrgDRI2DRIVER { DRI2DriverDRI
16617ca54c3Smrg	     DRI2DriverVDPAU }
16717ca54c3Smrg
16817ca54c3Smrg	These values describe the type of driver the client will want
16917ca54c3Smrg	to load.  The server sends back the name of the driver to use
17017ca54c3Smrg	for the screen in question.
17117ca54c3Smrg
17217ca54c3SmrgDRI2ATTACHMENT { DRI2BufferFrontLeft
17317ca54c3Smrg	       	 DRI2BufferBackLeft
17417ca54c3Smrg	       	 DRI2BufferFrontRight
17517ca54c3Smrg	       	 DRI2BufferBackRight
17617ca54c3Smrg	       	 DRI2BufferDepth
17717ca54c3Smrg	       	 DRI2BufferStencil
17817ca54c3Smrg	       	 DRI2BufferAccum
17917ca54c3Smrg		 DRI2BufferFakeFrontLeft
18017ca54c3Smrg		 DRI2BufferFakeFrontRight
18117ca54c3Smrg		 DRI2BufferDepthStencil
18217ca54c3Smrg		 DRI2BufferHiz }
18317ca54c3Smrg
18417ca54c3Smrg	These values describe various attachment points for DRI2
18517ca54c3Smrg	buffers.
18617ca54c3Smrg
18717ca54c3SmrgDRI2BUFFER { attachment: CARD32
18817ca54c3Smrg    	     name: CARD32
18917ca54c3Smrg	     pitch: CARD32
19017ca54c3Smrg    	     cpp: CARD32
19117ca54c3Smrg	     flags: CARD32 }
19217ca54c3Smrg
193d63b911fSmrg	The DRI2BUFFER describes an auxiliary rendering buffer
19417ca54c3Smrg	associated with an X drawable.  'attachment' describes the
19517ca54c3Smrg	attachment point for the buffer, 'name' is the name of the
19617ca54c3Smrg	underlying kernel buffer,
19717ca54c3Smrg
19817ca54c3Smrg
19917ca54c3SmrgDRI2ATTACH_FORMAT { attachment: CARD32
20017ca54c3Smrg		    format:     CARD32 }
20117ca54c3Smrg
20217ca54c3Smrg	The DRI2ATTACH_FORMAT describes an attachment and the associated
20317ca54c3Smrg	format.  'attachment' describes the attachment point for the buffer,
20417ca54c3Smrg	'format' describes an opaque, device-dependent format for the buffer.
20517ca54c3Smrg
20617ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
20717ca54c3Smrg
20817ca54c3Smrg
20917ca54c3Smrg7. Extension Initialization
21017ca54c3Smrg
21117ca54c3SmrgThe name of this extension is "DRI2".
21217ca54c3Smrg
21317ca54c3Smrg┌───
21417ca54c3Smrg    DRI2QueryVersion
21517ca54c3Smrg	client-major-version:	CARD32
21617ca54c3Smrg	client-minor-version:	CARD32
21717ca54c3Smrg21817ca54c3Smrg	major-version:		CARD32
21917ca54c3Smrg	minor-version:		CARD32
22017ca54c3Smrg└───
22117ca54c3Smrg
22217ca54c3Smrg	The client sends the highest supported version to the server
22317ca54c3Smrg	and the server sends the highest version it supports, but no
22417ca54c3Smrg	higher than the requested version. Major versions changes can
22517ca54c3Smrg	introduce incompatibilities in existing functionality, minor
22617ca54c3Smrg	version changes introduce only backward compatible changes.
22717ca54c3Smrg	It is the clients responsibility to ensure that the server
22817ca54c3Smrg	supports a version which is compatible with its expectations.
22917ca54c3Smrg
23017ca54c3Smrg	Backwards compatible changes included addition of new
23117ca54c3Smrg	requests, but also new value types in the DRI2CopyRegion
23217ca54c3Smrg	request.  When new values are introduced, the minor version
23317ca54c3Smrg	will be increased so the client can know which values the X
23417ca54c3Smrg	server understands from the version number.
23517ca54c3Smrg
23617ca54c3Smrg
23717ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
23817ca54c3Smrg
23917ca54c3Smrg
24017ca54c3Smrg8. Extension Requests
24117ca54c3Smrg
24217ca54c3Smrg┌───
24317ca54c3Smrg    DRI2Connect
24417ca54c3Smrg	window: WINDOW
24517ca54c3Smrg	driverType: DRI2DRIVER
24617ca54c3Smrg24717ca54c3Smrg	driver: STRING
24817ca54c3Smrg	device: STRING
24917ca54c3Smrg└───
25017ca54c3Smrg
25117ca54c3Smrg	Returns the driver name and device file to use for the
25217ca54c3Smrg	specified driver type for the screen associated with 'window'.
25317ca54c3Smrg
25417ca54c3Smrg	'type' identifies the type of driver to query for.
25517ca54c3Smrg
25617ca54c3Smrg	'driver' is the name of the driver to load.  The client is
25717ca54c3Smrg	assumed to know where to look for the drivers and what to do
25817ca54c3Smrg	with it.
25917ca54c3Smrg
26017ca54c3Smrg	'device' is the filename of the DRM device file.
26117ca54c3Smrg
26217ca54c3Smrg	If the client is not local, or the request driver type is
26317ca54c3Smrg	unknown or not available, 'driver' and 'device' will be empty
26417ca54c3Smrg	strings.  We are not using an regular X
26517ca54c3Smrg	error here to indicate failure, which will allow the client
26617ca54c3Smrg	fall back to other options more easily.
26717ca54c3Smrg
26817ca54c3Smrg	ISSUE: We could add the list of supported attachments and the
26917ca54c3Smrg	supported DRI2CopyRegion values here (just the bitmask of all
27017ca54c3Smrg	supported values).
27117ca54c3Smrg	
27217ca54c3Smrg┌───
27317ca54c3Smrg    DRI2Authenticate
27417ca54c3Smrg	window: WINDOW
27517ca54c3Smrg	token: CARD32
27617ca54c3Smrg27717ca54c3Smrg        authenticated: CARD32
27817ca54c3Smrg└───
27917ca54c3Smrg	Errors: Window
28017ca54c3Smrg
28117ca54c3Smrg	Request that the X server authenticates 'token', allowing the
28217ca54c3Smrg	client to access the DRM buffers created by the X server on
28317ca54c3Smrg	the screen associated with 'window'.
28417ca54c3Smrg
28517ca54c3Smrg	Authentication shouldn't fail at this point, except if an
28617ca54c3Smrg	invalid token is passed, in which case authenticated is False.
28717ca54c3Smrg
28817ca54c3Smrg┌───
28917ca54c3Smrg    DRI2GetBuffers
29017ca54c3Smrg	drawable: DRAWABLE
29117ca54c3Smrg	attachments: LISTofDRI2ATTACHMENTS
29217ca54c3Smrg29317ca54c3Smrg	width, height: CARD32
29417ca54c3Smrg	buffers: LISTofDRI2BUFFER
29517ca54c3Smrg└───
29617ca54c3Smrg	Errors: Window
29717ca54c3Smrg
29817ca54c3Smrg	Get buffers for the provided attachment points for the given
29917ca54c3Smrg	drawable.
30017ca54c3Smrg
30117ca54c3Smrg	If the DDX driver does not support one or more of the
30217ca54c3Smrg	specified attachment points, a Value error is generated, with
30317ca54c3Smrg	the first unsupported attachment point as the error value.
30417ca54c3Smrg
30517ca54c3Smrg	'width' and 'height' describes the dimensions of the drawable.
30617ca54c3Smrg
30717ca54c3Smrg	'buffers' is a list of DRI2BUFFER for the given DRI2
30817ca54c3Smrg	attachment points.
30917ca54c3Smrg
31017ca54c3Smrg┌───
31117ca54c3Smrg    DRI2CopyRegion
31217ca54c3Smrg	drawable: DRAWABLE
31317ca54c3Smrg	region: REGION
31417ca54c3Smrg	source: DRI2ATTACHMENT
31517ca54c3Smrg	destination: DRI2ATTACHMENT
31617ca54c3Smrg31717ca54c3Smrg└───
31817ca54c3Smrg	Errors: Window, Value
31917ca54c3Smrg
32017ca54c3Smrg	Schedule a copy from one DRI2 buffer to another.
32117ca54c3Smrg
32217ca54c3Smrg	The DRICopyRegion request has a reply but it is empty.  The
32317ca54c3Smrg	reply is there to let the direct rendering client wait until
32417ca54c3Smrg	the server has seen the request before proceeding with
32517ca54c3Smrg	rendering the next frame.
32617ca54c3Smrg
32717ca54c3Smrg┌───
32817ca54c3Smrg    DRI2SwapBuffers
32917ca54c3Smrg	drawable: DRAWABLE
33017ca54c3Smrg	target_msc: two CARD32s
33117ca54c3Smrg	divisor: two CARD32s
33217ca54c3Smrg	remainder: two CARD32s
33317ca54c3Smrg33417ca54c3Smrg	swap: two CARD32s
33517ca54c3Smrg└───
33617ca54c3Smrg	Errors: Window
33717ca54c3Smrg
33817ca54c3Smrg	Schedule a swap of the front and back buffers with the display
33917ca54c3Smrg	server.
34017ca54c3Smrg
34117ca54c3Smrg	Returns the swap count value when the swap will actually occur (e.g.
34217ca54c3Smrg	the last queued swap count + (pending swap count * swap interval)).
34317ca54c3Smrg
34417ca54c3Smrg	This request is only available with protocol version 1.2 or
34517ca54c3Smrg	later.
34617ca54c3Smrg
34717ca54c3Smrg┌───
34817ca54c3Smrg    DRI2GetBuffersWithFormat
34917ca54c3Smrg	drawable: DRAWABLE
35017ca54c3Smrg	attachments: LISTofDRI2ATTACH_FORMAT
35117ca54c3Smrg35217ca54c3Smrg	width, height: CARD32
35317ca54c3Smrg	buffers: LISTofDRI2BUFFER
35417ca54c3Smrg└───
35517ca54c3Smrg	Errors: Window
35617ca54c3Smrg
35717ca54c3Smrg	Get buffers for the provided attachment points with the specified
35817ca54c3Smrg	formats for the given drawable.
35917ca54c3Smrg
36017ca54c3Smrg	If the DDX driver does not support one or more of the
36117ca54c3Smrg	specified attachment points or formats, a Value error is generated,
36217ca54c3Smrg	with the first unsupported attachment point as the error value.
36317ca54c3Smrg
36417ca54c3Smrg	'width' and 'height' describes the dimensions of the drawable.
36517ca54c3Smrg
36617ca54c3Smrg	'buffers' is a list of DRI2BUFFER for the given DRI2
36717ca54c3Smrg	attachment points.
36817ca54c3Smrg
36917ca54c3Smrg	This request is only available with protocol version 1.1 or
37017ca54c3Smrg	later.
37117ca54c3Smrg
37217ca54c3Smrg┌───
37317ca54c3Smrg    DRI2GetMSC
37417ca54c3Smrg	drawable: DRAWABLE
37517ca54c3Smrg37617ca54c3Smrg	ust, msc, sbc: CARD64
37717ca54c3Smrg└───
37817ca54c3Smrg	Errors: Window
37917ca54c3Smrg
38017ca54c3Smrg	Get the current media stamp counter (MSC) and swap buffer count (SBC)
38117ca54c3Smrg	along with the unadjusted system time (UST) when the MSC was last
38217ca54c3Smrg	incremented.
38317ca54c3Smrg
38417ca54c3Smrg	This request is only available with protocol version 1.2 or
38517ca54c3Smrg	later.
38617ca54c3Smrg
38717ca54c3Smrg┌───
38817ca54c3Smrg    DRI2WaitMSC
38917ca54c3Smrg	drawable: DRAWABLE
39017ca54c3Smrg	target_msc: two CARD32s
39117ca54c3Smrg	divisor: two CARD32s
39217ca54c3Smrg	remainder: two CARD32s
39317ca54c3Smrg39417ca54c3Smrg	ust, msc, sbc: CARD64
39517ca54c3Smrg└───
39617ca54c3Smrg	Errors: Window
39717ca54c3Smrg
39817ca54c3Smrg	Blocks the client until either the frame count reaches target_msc or,
39917ca54c3Smrg	if the frame count is already greater than target_msc when the request
40017ca54c3Smrg	is received, until the frame count % divisor = remainder.  If divisor
40117ca54c3Smrg	is 0, the client will be unblocked if the frame count is greater than
40217ca54c3Smrg	or equal to the target_msc.
40317ca54c3Smrg
40417ca54c3Smrg	Returns the current media stamp counter (MSC) and swap buffer count
40517ca54c3Smrg	(SBC) along with the unadjusted system time (UST) when the MSC was last
40617ca54c3Smrg	incremented.
40717ca54c3Smrg
40817ca54c3Smrg	This request is only available with protocol version 1.2 or
40917ca54c3Smrg	later.
41017ca54c3Smrg
41117ca54c3Smrg┌───
41217ca54c3Smrg    DRI2WaitSBC
41317ca54c3Smrg	drawable: DRAWABLE
41417ca54c3Smrg	target_sbc: two CARD32s
41517ca54c3Smrg41617ca54c3Smrg	ust, msc, sbc: CARD64
41717ca54c3Smrg└───
41817ca54c3Smrg	Errors: Window
41917ca54c3Smrg
42017ca54c3Smrg	Blocks the client until the swap buffer count reaches target_sbc.  If
42117ca54c3Smrg	the swap buffer count is already greater than or equal to target_sbc
42217ca54c3Smrg	when the request is received, this request will return immediately.
42317ca54c3Smrg
42417ca54c3Smrg	If target_sbc is 0, this request will block the client until all
42517ca54c3Smrg	previous DRI2SwapBuffers requests have completed.
42617ca54c3Smrg
42717ca54c3Smrg	Returns the current media stamp counter (MSC) and swap buffer count
42817ca54c3Smrg	(SBC) along with the unadjusted system time (UST) when the MSC was last
42917ca54c3Smrg	incremented.
43017ca54c3Smrg
43117ca54c3Smrg	This request is only available with protocol version 1.2 or
43217ca54c3Smrg	later.
43317ca54c3Smrg
43417ca54c3Smrg┌───
43517ca54c3Smrg    DRI2SwapInterval
43617ca54c3Smrg	drawable: DRAWABLE
43717ca54c3Smrg	interval: CARD32
43817ca54c3Smrg43917ca54c3Smrg└───
44017ca54c3Smrg	Errors: Window
44117ca54c3Smrg
44217ca54c3Smrg	Sets the swap interval for DRAWABLE.  This will throttle
44317ca54c3Smrg	DRI2SwapBuffers requests to swap at most once per interval frames,
44417ca54c3Smrg	which is useful useful for limiting the frame rate.
44517ca54c3Smrg
44617ca54c3Smrg┌───
44717ca54c3Smrg    DRI2GetParam
44817ca54c3Smrg	drawable: DRAWABLE
44917ca54c3Smrg	param: CARD32
45017ca54c3Smrg45117ca54c3Smrg	is_param_recognized: BOOL
45217ca54c3Smrg	value: CARD64
45317ca54c3Smrg└───
45417ca54c3Smrg	Errors: Drawable
45517ca54c3Smrg
45617ca54c3Smrg	Get the value of a parameter.  The parameter's value is looked up on
45717ca54c3Smrg	the screen associated with 'drawable'.
45817ca54c3Smrg
45917ca54c3Smrg	Parameter names in which the value of the most significant byte is
46017ca54c3Smrg	0 are reserved for the X server. Currently, no such parameter names
46117ca54c3Smrg	are defined. (When any such names are defined, they will be defined in
46217ca54c3Smrg	this extension specification and its associated headers).
46317ca54c3Smrg
46417ca54c3Smrg	Parameter names in which the byte's value is 1 are reserved for the
46517ca54c3Smrg	DDX. Such names are private to each driver and shall be defined in the
46617ca54c3Smrg	respective driver's headers.
46717ca54c3Smrg
46817ca54c3Smrg	Parameter names in which the byte's value is neither 0 nor 1 are
46917ca54c3Smrg	reserved for future use.
47017ca54c3Smrg
47117ca54c3Smrg	Possible values of 'is_param_recognized' are true (1) and false (0).
47217ca54c3Smrg	If false, then 'value' is undefined.
47317ca54c3Smrg
47417ca54c3Smrg	This request is only available with protocol version 1.4 or later.
47517ca54c3Smrg
47617ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
47717ca54c3Smrg
47817ca54c3Smrg9. Extension Events
47917ca54c3Smrg
48017ca54c3Smrg┌───
48117ca54c3Smrg    DRI2BufferSwapComplete
48217ca54c3Smrg48317ca54c3Smrg      	event_type: CARD16
48417ca54c3Smrg	drawable: CARD32
48517ca54c3Smrg	ust: CARD64
48617ca54c3Smrg	msc: CARD64
48717ca54c3Smrg	sbc: CARD64
48817ca54c3Smrg└───
48917ca54c3Smrg
49017ca54c3Smrg	This event reports the status of the last DRI2SwapBuffers event to
49117ca54c3Smrg	the client.  The event type should be one of DRI2_EXCHANGE_COMPLETE,
49217ca54c3Smrg	indicating a successful buffer exchange, DRI2_BLIT_COMPLETE, indicating
49317ca54c3Smrg	the swap was performed with a blit, and DRI2_FLIP_COMPLETE, indicating
49417ca54c3Smrg	a full page flip was completed.
49517ca54c3Smrg
49617ca54c3Smrg┌───
49717ca54c3Smrg    DRI2InvalidateBuffers
49817ca54c3Smrg49917ca54c3Smrg	drawable: CARD32
50017ca54c3Smrg└───
50117ca54c3Smrg
50217ca54c3Smrg	This event is generated when the buffers the client had
50317ca54c3Smrg	requested for 'drawable' (with DRI2GetBuffers or
50417ca54c3Smrg	DRI2GetBuffersWithFormat) become inappropriate because they
50517ca54c3Smrg	don't match the drawable dimensions anymore, or a buffer swap
50617ca54c3Smrg	has been performed.
50717ca54c3Smrg
50817ca54c3Smrg	Note that the server is only required to warn the client once
50917ca54c3Smrg	about this condition, until the client takes care of bringing
51017ca54c3Smrg	them back up-to-date with another GetBuffers request.
51117ca54c3Smrg
51217ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
51317ca54c3Smrg
51417ca54c3Smrg10. Extension Versioning
51517ca54c3Smrg
51617ca54c3SmrgThe DRI2 extension has undergone a number of revisions before
51717ca54c3Smrg
51817ca54c3Smrg	1.0: Released, but never used.  Relied on a number of
51917ca54c3Smrg		constructs from the XF86DRI extension, such as a
52017ca54c3Smrg		shared memory area (SAREA) to communicate changes in
52117ca54c3Smrg		cliprects and window sizes, and
52217ca54c3Smrg
52317ca54c3Smrg	1.99.1: Move the swap buffer functionality into the X server,
52417ca54c3Smrg		introduce SwapBuffer request to copy back buffer
52517ca54c3Smrg		contents to the X drawable.
52617ca54c3Smrg
52717ca54c3Smrg	1.99.2: Rethink the SwapBuffer request as an asynchronous
52817ca54c3Smrg		request to copy a region between DRI2 buffers.  Drop
52917ca54c3Smrg		CreateDrawable and DestroyDrawable, update Connect to
53017ca54c3Smrg		support different driver types and to send the
53117ca54c3Smrg		authentication group.
53217ca54c3Smrg
53317ca54c3Smrg	1.99.3: Drop the bitmask argument intended to indicate
53417ca54c3Smrg		presence of optional arguments for CopyRegion.
53517ca54c3Smrg
53617ca54c3Smrg	2.0: Awesomeness!
53717ca54c3Smrg
53817ca54c3Smrg	2.1: True excellence.  Added DRI2GetBuffersWithFormat to allow
53917ca54c3Smrg             more flexible object creation.
54017ca54c3Smrg
54117ca54c3Smrg	2.2: Approaching perfection.  Added requests for swapbuffers,
54217ca54c3Smrg             MSC and SBC related requests, and events.
54317ca54c3Smrg
54417ca54c3Smrg	2.3: Added the DRI2InvalidateBuffers event.
54517ca54c3Smrg
54617ca54c3Smrg	2.6: Enlightenment attained.  Added the DRI2BufferHiz attachment.
54717ca54c3Smrg
54817ca54c3Smrg	2.7: Added the DRI2GetParam request.
54917ca54c3Smrg
55017ca54c3SmrgCompatibility up to 2.0 is not preserved, but was also never released.
55117ca54c3Smrg
55217ca54c3Smrg
55317ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
55417ca54c3Smrg
55517ca54c3Smrg
55617ca54c3Smrg11. Relationship with other extensions
55717ca54c3Smrg
55817ca54c3SmrgAs an extension designed to support other extensions, there is
55917ca54c3Smrgnaturally some interactions with other extensions.
56017ca54c3Smrg
56117ca54c3Smrg
56217ca54c3Smrg11.1 GLX
56317ca54c3Smrg
564d63b911fSmrgThe GL auxiliary buffers map directly to the DRI2 buffers... eh
56517ca54c3Smrg
56617ca54c3Smrg
56717ca54c3Smrg11.2 DBE
56817ca54c3Smrg
56917ca54c3SmrgThe DBE back buffer must correspond to the DRI2_BUFFER_FRONT_LEFT
57017ca54c3SmrgDRI2 buffer for servers that support both DBE and DRI2.
57117ca54c3Smrg
57217ca54c3Smrg
57317ca54c3Smrg11.3 XvMC / Xv
57417ca54c3Smrg
57517ca54c3SmrgWe might add a DRI2_BUFFER_YUV to do vsynced colorspace conversion
57617ca54c3Smrgblits.  Maybe... not really sure.
57717ca54c3Smrg
57817ca54c3Smrg
57917ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
58017ca54c3Smrg
58117ca54c3Smrg
58217ca54c3SmrgAppendix A. Protocol Encoding
58317ca54c3Smrg
58417ca54c3SmrgSyntactic Conventions
58517ca54c3Smrg
58617ca54c3SmrgThis document uses the same syntactic conventions as the core X
58717ca54c3Smrgprotocol encoding document.
58817ca54c3Smrg
58917ca54c3Smrg
59017ca54c3SmrgA.1 Common Types
59117ca54c3Smrg
59217ca54c3Smrg┌───
59317ca54c3Smrg    DRI2DRIVER
59417ca54c3Smrg	0x0	DRI2DriverDRI
59517ca54c3Smrg	0x1	DRI2DriverVDPAU
59617ca54c3Smrg└───
59717ca54c3Smrg
59817ca54c3Smrg┌───
59917ca54c3Smrg    DRI2ATTACHMENT
60017ca54c3Smrg	0x0	DRI2BufferFrontLeft
60117ca54c3Smrg	0x1	DRI2BufferBackLeft
60217ca54c3Smrg	0x2	DRI2BufferFrontRight
60317ca54c3Smrg	0x3	DRI2BufferBackRight
60417ca54c3Smrg	0x4	DRI2BufferDepth
60517ca54c3Smrg	0x5	DRI2BufferStencil
60617ca54c3Smrg	0x6	DRI2BufferAccum
60717ca54c3Smrg	0x7	DRI2BufferFakeFrontLeft
60817ca54c3Smrg	0x8	DRI2BufferFakeFrontRight
60917ca54c3Smrg	0x9	DRI2BufferDepthStencil
61017ca54c3Smrg	0xa	DRI2BufferHiz
61117ca54c3Smrg└───
61217ca54c3Smrg	Used to encode the possible attachment points.  The attachment
61317ca54c3Smrg	DRI2BufferDepthStencil is only available with protocol version 1.1 or
61417ca54c3Smrg	later.
61517ca54c3Smrg
61617ca54c3Smrg┌───
61717ca54c3Smrg    DRI2BUFFER
61817ca54c3Smrg	4	CARD32	attachment
61917ca54c3Smrg	4	CARD32	name
62017ca54c3Smrg	4	CARD32	pitch
62117ca54c3Smrg	4	CARD32	cpp
62217ca54c3Smrg	4	CARD32	flags
62317ca54c3Smrg└───
62417ca54c3Smrg	A DRI2 buffer specifies the attachment, the kernel memory
62517ca54c3Smrg	manager name, the pitch and chars per pixel for a buffer
62617ca54c3Smrg	attached to a given drawable.
62717ca54c3Smrg
62817ca54c3Smrg┌───
62917ca54c3Smrg    DRI2ATTACH_FORMAT
63017ca54c3Smrg	4	CARD32	attachment
63117ca54c3Smrg	4	CARD32	format
63217ca54c3Smrg└───
63317ca54c3Smrg	Used to describe the attachment and format requested from the server.
63417ca54c3Smrg	This data type is only available with protocol version 1.1 or
63517ca54c3Smrg	later.
63617ca54c3Smrg
63717ca54c3SmrgA.2 Protocol Requests
63817ca54c3Smrg
63917ca54c3Smrg┌───
64017ca54c3Smrg    DRI2QueryVersion
64117ca54c3Smrg	1	CARD8			major opcode
64217ca54c3Smrg	1	0			DRI2 opcode
64317ca54c3Smrg	2	3			length
64417ca54c3Smrg	4	CARD32			major version
64517ca54c3Smrg	4	CARD32			minor version
64617ca54c3Smrg64717ca54c3Smrg	1	1			Reply
64817ca54c3Smrg        1				unused
64917ca54c3Smrg	2	CARD16			sequence number
65017ca54c3Smrg	4	0			reply length
65117ca54c3Smrg	4	CARD32			major version
65217ca54c3Smrg        4	CARD32			minor version
65317ca54c3Smrg	16				unused	
65417ca54c3Smrg└───
65517ca54c3Smrg
65617ca54c3Smrg┌───
65717ca54c3Smrg    DRI2Connect
65817ca54c3Smrg	1	CARD8			major opcode
65917ca54c3Smrg	1	1			DRI2 opcode
66017ca54c3Smrg	2	3			length
66117ca54c3Smrg	4	WINDOW			window
66217ca54c3Smrg	4	CARD32			driver type
66317ca54c3Smrg66417ca54c3Smrg	1	1			Reply
66517ca54c3Smrg        1				unused
66617ca54c3Smrg	2	CARD16			sequence number
66717ca54c3Smrg	4	(n+m+p+q)/4		reply length
66817ca54c3Smrg	4	n			driver name length
66917ca54c3Smrg	4	m			device name length
67017ca54c3Smrg	16				unused
67117ca54c3Smrg	n	CARD8			driver name
67217ca54c3Smrg	p				unused, p=pad(n)
67317ca54c3Smrg	m	CARD8			device name
67417ca54c3Smrg	q				unused, q=pad(m)
67517ca54c3Smrg└───
67617ca54c3Smrg
67717ca54c3Smrg┌───
67817ca54c3Smrg    DRI2Authenticate
67917ca54c3Smrg	1	CARD8			major opcode
68017ca54c3Smrg	1	2			DRI2 opcode
68117ca54c3Smrg	2	3			length
68217ca54c3Smrg	4	WINDOW			window
68317ca54c3Smrg	4	CARD32			authentication token
68417ca54c3Smrg68517ca54c3Smrg	1	1			Reply
68617ca54c3Smrg        1				unused
68717ca54c3Smrg	2	CARD16			sequence number
68817ca54c3Smrg	4	0			reply length
68917ca54c3Smrg	4	CARD32			authenticated
69017ca54c3Smrg	20				unused	
69117ca54c3Smrg└───
69217ca54c3Smrg
69317ca54c3Smrg┌───
69417ca54c3Smrg    DRI2GetBuffers
69517ca54c3Smrg	1	CARD8			major opcode
69617ca54c3Smrg	1	5			DRI2 opcode
69717ca54c3Smrg	2	3			length
69817ca54c3Smrg	4	DRAWABLE		drawable
69917ca54c3Smrg	4	n			number of attachments
70017ca54c3Smrg	4n	LISTofDRI2ATTACHMENTS	attachments
70117ca54c3Smrg70217ca54c3Smrg	1	1			Reply
70317ca54c3Smrg        1				unused
70417ca54c3Smrg	2	CARD16			sequence number
70517ca54c3Smrg	4	0			reply length
70617ca54c3Smrg	4	CARD32			width of drawable
70717ca54c3Smrg	4	CARD32			height of drawable
70817ca54c3Smrg	4	CARD32			buffer count
70917ca54c3Smrg	12				unused	
71017ca54c3Smrg	5n	LISTofDRI2BUFFER	buffers
71117ca54c3Smrg└───
71217ca54c3Smrg
71317ca54c3Smrg┌───
71417ca54c3Smrg    DRI2CopyRegion
71517ca54c3Smrg	1	CARD8			major opcode
71617ca54c3Smrg	1	6			DRI2 opcode
71717ca54c3Smrg	2	3			length
71817ca54c3Smrg	4	DRAWABLE		drawable
71917ca54c3Smrg	4	REGION			region
72017ca54c3Smrg	4	DRI2ATTACHMENT		source
72117ca54c3Smrg	4	DRI2ATTACHMENT		destination
72217ca54c3Smrg72317ca54c3Smrg	1	1			Reply
72417ca54c3Smrg        1				unused
72517ca54c3Smrg	2	CARD16			sequence number
72617ca54c3Smrg	4	0			reply length
72717ca54c3Smrg	24				unused	
72817ca54c3Smrg└───
72917ca54c3Smrg
73017ca54c3Smrg┌───
73117ca54c3Smrg    DRI2GetBuffersWithFormat
73217ca54c3Smrg	1	CARD8			major opcode
73317ca54c3Smrg	1	7			DRI2 opcode
73417ca54c3Smrg	2	3			length
73517ca54c3Smrg	4	DRAWABLE		drawable
73617ca54c3Smrg	4	n			number of attachments
73717ca54c3Smrg	8n	LISTofDRI2ATTACH_FORMAT	attachments and formats
73817ca54c3Smrg73917ca54c3Smrg	1	1			Reply
74017ca54c3Smrg       1				unused
74117ca54c3Smrg	2	CARD16			sequence number
74217ca54c3Smrg	4	0			reply length
74317ca54c3Smrg	4	CARD32			width of drawable
74417ca54c3Smrg	4	CARD32			height of drawable
74517ca54c3Smrg	4	CARD32			buffer count
74617ca54c3Smrg	12				unused	
74717ca54c3Smrg	5n	LISTofDRI2BUFFER	buffers
74817ca54c3Smrg└───
74917ca54c3Smrg
75017ca54c3Smrg┌───
75117ca54c3Smrg    DRI2SwapBuffers
75217ca54c3Smrg	1	CARD8			major opcode
75317ca54c3Smrg	1	8			DRI2 opcode
75417ca54c3Smrg	2	8			length
75517ca54c3Smrg	4	DRAWABLE		drawable
75617ca54c3Smrg	4	CARD32			target_msc_hi
75717ca54c3Smrg	4	CARD32			target_msc_lo
75817ca54c3Smrg	4	CARD32			divisor_hi
75917ca54c3Smrg	4	CARD32			divisor_lo
76017ca54c3Smrg	4	CARD32			remainder_hi
76117ca54c3Smrg	4	CARD32			remainder_lo
76217ca54c3Smrg76317ca54c3Smrg	1	1			Reply
76417ca54c3Smrg        1				unused
76517ca54c3Smrg	2	CARD16			sequence number
76617ca54c3Smrg	4	0			reply length
76717ca54c3Smrg	4	CARD32			swap_hi
76817ca54c3Smrg	4	CARD32			swap_lo
76917ca54c3Smrg	20				unused
77017ca54c3Smrg└───
77117ca54c3Smrg
77217ca54c3Smrg┌───
77317ca54c3Smrg    DRI2GetMSC
77417ca54c3Smrg	1	CARD8			major opcode
77517ca54c3Smrg	1	9			DRI2 opcode
77617ca54c3Smrg	2	8			length
77717ca54c3Smrg	4	DRAWABLE		drawable
77817ca54c3Smrg77917ca54c3Smrg	1	1			Reply
78017ca54c3Smrg        1				unused
78117ca54c3Smrg	2	CARD16			sequence number
78217ca54c3Smrg	4	0			reply length
78317ca54c3Smrg	4	CARD32			ust_hi
78417ca54c3Smrg	4	CARD32			ust_lo
78517ca54c3Smrg	4	CARD32			msc_hi
78617ca54c3Smrg	4	CARD32			msc_lo
78717ca54c3Smrg	4	CARD32			sbc_hi
78817ca54c3Smrg	4	CARD32			sbc_lo
78917ca54c3Smrg└───
79017ca54c3Smrg
79117ca54c3Smrg┌───
79217ca54c3Smrg    DRI2WaitMSC
79317ca54c3Smrg	1	CARD8			major opcode
79417ca54c3Smrg	1	10			DRI2 opcode
79517ca54c3Smrg	2	8			length
79617ca54c3Smrg	4	DRAWABLE		drawable
79717ca54c3Smrg	4	CARD32			target_msc_hi
79817ca54c3Smrg	4	CARD32			target_msc_lo
79917ca54c3Smrg	4	CARD32			divisor_hi
80017ca54c3Smrg	4	CARD32			divisor_lo
80117ca54c3Smrg	4	CARD32			remainder_hi
80217ca54c3Smrg	4	CARD32			remainder_lo
80317ca54c3Smrg80417ca54c3Smrg	1	1			Reply
80517ca54c3Smrg        1				unused
80617ca54c3Smrg	2	CARD16			sequence number
80717ca54c3Smrg	4	0			reply length
80817ca54c3Smrg	4	CARD32			ust_hi
80917ca54c3Smrg	4	CARD32			ust_lo
81017ca54c3Smrg	4	CARD32			msc_hi
81117ca54c3Smrg	4	CARD32			msc_lo
81217ca54c3Smrg	4	CARD32			sbc_hi
81317ca54c3Smrg	4	CARD32			sbc_lo
81417ca54c3Smrg└───
81517ca54c3Smrg
81617ca54c3Smrg┌───
81717ca54c3Smrg    DRI2WaitSBC
81817ca54c3Smrg	1	CARD8			major opcode
81917ca54c3Smrg	1	11			DRI2 opcode
82017ca54c3Smrg	2	8			length
82117ca54c3Smrg	4	DRAWABLE		drawable
82217ca54c3Smrg 	4	CARD32			swap_hi
82317ca54c3Smrg	4	CARD32			swap_lo
82417ca54c3Smrg82517ca54c3Smrg	1	1			Reply
82617ca54c3Smrg        1				unused
82717ca54c3Smrg	2	CARD16			sequence number
82817ca54c3Smrg	4	0			reply length
82917ca54c3Smrg	4	CARD32			ust_hi
83017ca54c3Smrg	4	CARD32			ust_lo
83117ca54c3Smrg	4	CARD32			msc_hi
83217ca54c3Smrg	4	CARD32			msc_lo
83317ca54c3Smrg	4	CARD32			sbc_hi
83417ca54c3Smrg	4	CARD32			sbc_lo
83517ca54c3Smrg└───
83617ca54c3Smrg
83717ca54c3Smrg┌───
83817ca54c3Smrg    DRI2SwapInterval
83917ca54c3Smrg	1	CARD8			major opcode
84017ca54c3Smrg	1	12			DRI2 opcode
84117ca54c3Smrg	2	8			length
84217ca54c3Smrg	4	DRAWABLE		drawable
84317ca54c3Smrg 	4	CARD32			interval
84417ca54c3Smrg84517ca54c3Smrg└───
84617ca54c3Smrg
84717ca54c3Smrg┌───
84817ca54c3Smrg    DRI2GetParam
84917ca54c3Smrg	1	CARD8			major opcode
85017ca54c3Smrg	1	13			DRI2 opcode
85117ca54c3Smrg	2	8			length
85217ca54c3Smrg	4	DRAWABLE		drawable
85317ca54c3Smrg	4	CARD32			param
85417ca54c3Smrg85517ca54c3Smrg	1	1			Reply
85617ca54c3Smrg	1	BOOL			is_param_recognized
85717ca54c3Smrg	2	CARD16			sequence number
85817ca54c3Smrg	4	0			reply length
85917ca54c3Smrg	4	CARD32			value_hi
86017ca54c3Smrg	4	CARD32			value_lo
86117ca54c3Smrg	16				unused
86217ca54c3Smrg└───
86317ca54c3Smrg
86417ca54c3SmrgA.3 Protocol Events
86517ca54c3Smrg
86617ca54c3SmrgThe DRI2 extension specifies DRI2_BufferSwapComplete and
86717ca54c3SmrgDRI2_InvalidateBuffers events.
86817ca54c3Smrg
86917ca54c3Smrg┌───
87017ca54c3Smrg    DRI2_BufferSwapComplete
87117ca54c3Smrg	1	CARD8			type
87217ca54c3Smrg	1	CARD8			extension
87317ca54c3Smrg	2	CARD16			sequenceNumber
87417ca54c3Smrg	2	CARD16			event_type
87517ca54c3Smrg	4	DRAWABLE		drawable
87617ca54c3Smrg	4	CARD32			ust_hi
87717ca54c3Smrg	4	CARD32			ust_lo
87817ca54c3Smrg	4	CARD32			msc_hi
87917ca54c3Smrg	4	CARD32			msc_lo
88017ca54c3Smrg	4	CARD32			sbc_hi
88117ca54c3Smrg	4	CARD32			sbc_lo
88217ca54c3Smrg└───
88317ca54c3Smrg
88417ca54c3Smrg
88517ca54c3Smrg┌───
88617ca54c3Smrg    DRI2_InvalidateBuffers
88717ca54c3Smrg	1	CARD8			type
88817ca54c3Smrg	1	CARD8			extension
88917ca54c3Smrg	2	CARD16			sequenceNumber
89017ca54c3Smrg	4	DRAWABLE		drawable
89117ca54c3Smrg	4	CARD32			unused
89217ca54c3Smrg	4	CARD32			unused
89317ca54c3Smrg	4	CARD32			unused
89417ca54c3Smrg	4	CARD32			unused
89517ca54c3Smrg	4	CARD32			unused
89617ca54c3Smrg	4	CARD32			unused
89717ca54c3Smrg└───
89817ca54c3Smrg
89917ca54c3SmrgA.4 Protocol Errors
90017ca54c3Smrg
90117ca54c3SmrgThe DRI2 extension specifies no errors.
90217ca54c3Smrg
90317ca54c3Smrg
90417ca54c3Smrg			     ⚙ ⚙ ⚙  ⚙ ⚙ ⚙
90517ca54c3Smrg
90617ca54c3Smrg
90717ca54c3SmrgAppendix B. Implementation on GEM
90817ca54c3Smrg
90917ca54c3SmrgWhere to begin...
910