Direct Rendering Infrastructure

DRI-1.0
Original author(s) Precision Insight, Tungsten Graphics
Developer(s) freedesktop.org
Initial release August 1998 (1998-08)[1]
Stable release
2.4.x / February 2009
Development status maintained, marked for obsoletion
Written in C
Platform POSIX
Type Framework / API
License MIT and other licenses[2]
Website dri.freedesktop.org
DRI-2.0
Original author(s) Kristian Høgsberg et al.
Developer(s) freedesktop.org
Initial release September 4, 2008 (2008-09-04)[3]
Stable release
2.8 / July 11, 2012 (2012-07-11)[4]
Development status active
Written in C
Platform POSIX
Type Framework / API
License MIT and other licenses[2]
Website dri.freedesktop.org
DRI-3.0
Original author(s) Keith Packard et al.
Developer(s) freedesktop.org
Initial release November 1, 2013 (2013-11-01)[5]
Stable release
1.0 / November 1, 2013 (2013-11-01)[5]
Development status active
Written in C
Platform POSIX
Type Framework / API
License MIT and other licenses[2]
Website dri.freedesktop.org
There are two graphics hardware drivers: one resides inside of the X display server. There have been several designs of this driver. The current one splits it in two portions: DIX (Device-Independent X) and DDX (Device-Dependent X)
Glamor will simplify the X server, and libGL-fglrx-glx could use the libDRM of the radeon open-source driver instead of the proprietary binary blob.
Rendering calculations are outsourced over OpenGL to the GPU to be done in real-time. The DRI regulates access and book-keeping.

The Direct Rendering Infrastructure (DRI) is a framework for allowing direct access to graphics hardware under the X Window System in a safe, efficient way.[6] The main use of DRI is to provide hardware acceleration for the Mesa implementation of OpenGL. DRI has also been adapted to provide OpenGL acceleration on a framebuffer console without a display server running.

DRI implementation is scattered through the X Server and its associated client libraries, Mesa 3D and the Direct Rendering Manager kernel subsystem.[6] All of its source code is free software.

Overview

In the classic X Window System architecture the X Server is the only process with exclusive access to the graphics hardware, and therefore the one which does the actual rendering on the framebuffer. All that X clients do is communicate with the X Server to dispatch rendering commands. Those commands are hardware independent, meaning that the X11 protocol provides an API that abstracts the graphics device so the X clients don't need to know or worry about the specifics of the underlying hardware. Any hardware specific code lives inside the Device Dependent X, the part of the X Server that manages each type of video card or graphics adapter and which is also often called the video or graphics driver.

The rise of 3D rendering has shown the limits of this architecture. 3D graphics applications tend to produce large amounts of commands and data, all of which must be dispatched to the X Server for rendering. As the amount of inter-process communication (IPC) between the X client and X Server increased, the 3D rendering performance suffered to the point that X driver developers concluded that in order to take advantage of 3D hardware capabilities of the latest graphics cards a new IPC-less architecture was required. X clients should have direct access to graphics hardware rather than relying on a third party process to do so, saving all the IPC overload. This approach is called "direct rendering" as opposed to the "indirect rendering" provided by the classical X architecture. The Direct Rendering Infrastructure was initially developed to allow any X client to perform 3D rendering using this "direct rendering" approach.

It should be noted that nothing prevents DRI from being used to implement accelerated 2D direct rendering within an X client.[3] Simply no one has had the need to do so because the 2D indirect rendering performance was good enough.

Software architecture

The basic architecture of the Direct Rendering Infrastructure involves three main components:[7]

DRI1

In the original DRI architecture, due to the memory size of video cards at that time, there was a single instance of the screen front buffer and back buffer (also of the ancillary depth buffer and stencil buffer), shared by all the DRI clients and the X Server.[10][11] All of them rendered directly onto the back buffer, that was swapped with the front buffer at vertical blanking interval time.[10] In order to render to the back buffer, a DRI process should ensure that the rendering was clipped to the area reserved for its window.[10][11]

The synchronization with the X Server was done through signals and a shared memory buffer called the SAREA.[11] The access to the DRM device was exclusive, so any DRI client had to lock it at the beginning of a rendering operation. Other users of the device including the X Server were blocked in the meantime, and they had to wait until the lock was released at the end of the current rendering operation, even if it wouldn't be any conflict between both operations.[11] Another drawback was that operations didn't retain memory allocations after the current DRI process released its lock on the device, so any data uploaded to the graphics memory such as textures were lost for upcoming operations, causing a significant impact on graphics performance.

Nowadays DRI1 is considered completely obsolete and must not be used.

DRI2

Due to the increasing popularity of compositing window managers like Compiz, the Direct Rendering Infrastructure had to be redesigned so that X clients could also support redirection to "offscreen pixmaps" while doing direct rendering. Regular X clients already respected the redirection to a separate pixmap provided by the X Server as a render target the so-called offscreen pixmap, but DRI clients continued to do the rendering directly into the shared backbuffer, effectively bypassing the compositing window manager.[10][12] The ultimate solution was to change the way DRI handled the render buffers, which led to a completely different DRI extension with a new set of operations, and also major changes in the Direct Rendering Manager.[3] The new extension was named "DRI2", although it should be noted that it's not a later version but a different extension not even compatible with the original DRI in fact both have coexisted within the X Server for a long time.

In DRI2, instead of a single shared (back) buffer, every DRI client gets its own private back buffer[10][11] along with their associated depth and stencil buffers to render its window content using the hardware acceleration. The DRI client then swaps it with a false "front buffer",[11] which is used by the compositing window manager as one of the sources to compose (build) the final screen back buffer to be swapped at the VBLANK interval with the real front buffer.

To handle all these new buffers, the Direct Rendering Manager had to incorporate new functionality, specifically a graphics memory manager. DRI2 was initially developed using the experimental TTM memory manager,[10][12] but it was later rewritten to use GEM after it was chosen as the definitive DRM memory manager.[13] The new DRI2 internal buffer management model also solved two major performance bottlenecks present in the original DRI implementation:

In DRI2, the allocation of the private offscreen buffers (back buffer, fake front buffer, depth buffer, stencil buffer, ...) for a window is done by the X Server itself.[14][15] DRI clients retrieve those buffers to do the rendering into the window by calling operations such as DRI2GetBuffers and DRI2GetBuffersWithFormat available in the DRI2 extension.[3] Internally, DRI2 uses GEM names a type of global handle provided by the GEM API that allows two processes accessing a DRM device to refer to the same buffer for passing around "references" to those buffers thought the X11 protocol.[15] The reason why the X Server is in charge of the buffer allocation of the render buffers of a window is that the GLX extension allows for multiple X clients to do OpenGL rendering cooperatively in the same window.[14] This way, the X Server manages the whole lifecycle of the render buffers along the entire rendering process and knows when it can safely recycle or discard them. When a window resize is performed, the X Server is also responsible of allocating new render buffers matching the new window size, and notifying the change to the DRI client(s) rendering into the window using an InvalidateBuffers event, so they would retrieve the GEM names of the new buffers.[14]

The DRI2 extension provides other core operations for the DRI clients, such as finding out which DRM device and driver should they use (DRI2Connect) or getting authenticated by the X Server in order to be able to use the rendering and buffer facilities of the DRM device (DRI2Authenticate).[3] The presentation of the rendered buffers in the screen is performed using the DRI2CopyRegion and DRI2SwapBuffers requests. DRI2CopyRegion can be used to do a copy between the fake front buffer and the real front buffer, but it doesn't provide any synchronization with the vertical blanking interval, so it can cause tearing. DRI2SwapBuffers, on the other hand, performs a VBLANK-synchronized swap between back and front buffer, if it's supported and both buffers have the same size, or a copy (blit) otherwise.[3][14]

DRI3

Although DRI2 was a significant improvement over the original DRI, the new extension also introduced some new issues.[14][15] In 2013, a third iteration of the Direct Rendering Infrastructure known as DRI3 was developed in order to fix those issues.[16]

The main differences of DRI3 compared to DRI2 are:

Buffer allocation on the client side breaks GLX assumptions in the sense that it's no longer possible for multiple GLX applications to render cooperatively in the same window. On the plus side, the fact that the DRI client is in charge of its own buffers throughout their lifetime brings many advantages. For example, it is easy for the DRI3 client to ensure that the size of the render buffers always match the current size of the window, and thereby eliminate the artifacts due to the lack of synchronization of buffer sizes between client and server that plagued window resizing in DRI2.[14][15][17] A better performance is also achieved because now DRI3 clients save the extra round trip waiting for the X Server to send the render buffers.[15] DRI3 clients, and especially compositor window managers, can take advantage of keeping older buffers of previous frames and reusing them as the basis on which to render only the damaged parts of a window as another performance optimization.[14][15] The DRI3 extension no longer needs to be modified to support new particular buffer formats, since they are now handled directly between the DRI client driver and the DRM kernel driver.[14] The use of file descriptors, on the other hand, allows the kernel to perform a safe cleanup of any unused GEM buffer object one with no reference to it.[14][15]

Technically, DRI3 consists of two different extensions, the "DRI3" extension and the "Present" extension.[16][18] The main purpose of the DRI3 extension is to implement the mechanism to share direct rendered buffers between DRI clients and the X Server.[17][18][19] DRI clients allocate and use GEM buffers objects as rendering targets, while the X Server represents these render buffers using a type of X11 object called "pixmap". DRI3 provides two operations, DRI3PixmapFromBuffer and DRI3BufferFromPixmap, one to create a pixmap (in "X Server space") from a GEM buffer object (in "DRI client space"), and the other to do the reverse and get a GEM buffer object from an X pixmap.[17][18][19] In these DRI3 operations GEM buffer objects are passed as DMA-BUF file descriptors instead of GEM names. DRI3 also provides a way to share synchronization objects between the DRI client and the X Server, allowing both a serialized access to the shared buffer.[18] Unlike DRI2, the initial DRI3Open operation the first every DRI client must request to know which DRM device to use returns an already open file descriptor to the device node instead of the device node filename, with any required authentication procedure already performed in advance by the X Server.[17][18]

DRI3 provides no mechanism to show the rendered buffers on the screen, but relies on another extension, the Present extension, to do so.[19] Present is so named because its main task is to "present" buffers on the screen, meaning that it handles the update of the framebuffer using the contents of the rendered buffers delivered by client applications.[18] Screen updates have to be done at the proper time, normally during the VBLANK interval in order to avoid display artifacts such as tearing. Present also handles the synchronization of screen updates to the VBLANK interval.[20] It also keeps the X client informed about the instant each buffer is really shown on the screen using events, so the client can synchronize its rendering process with the current screen refresh rate.

Present accepts any X pixmap as the source for a screen update.[20] Since pixmaps are standard X objects, Present can be used not only by DRI3 clients performing direct rendering, but also by any X client rendering on a pixmap by any means.[17] For example, most existing non-GL based GTK+ and Qt applications used to do double buffered pixmap rendering using XRender. The Present extension can also be used by these applications to achieve efficient and non-tearing screen updates. This is the reason why Present was developed as a separate standalone extension instead of being part of DRI3.[17]

Apart from allowing non-GL X clients to synchronize with VBLANK, Present brings other advantages. DRI3 graphics performance is better because Present is more efficient than DRI2 in swapping buffers.[18] A number of OpenGL extensions that weren't available with DRI2 are now supported based on new features provided by Present.[18]

Present provides two main operations to X clients: update a region of a window using part of or all the contents of a pixmap (PresentPixmap) and set the type of presentation events related to a certain window that the client wants to be notified about (PresentSelectInput).[18][20] There are three presentation events about which a window can notify an X client: when an ongoing presentation operation normally from a call to PresentPixmap has been completed (PresentCompleteNotify), when a pixmap used by a PresentPixmap operation is ready to be reused (PresentIdleNotify) and when the window configuration mostly window size changes (PresentConfigureNotify).[18][20] Whether a PresentPixmap operation performs a direct copy (blit) onto the front buffer or a swap of the entire back buffer with the front buffer is an internal detail of the Present extension implementation, instead of an explicit choice of the X client as it was in DRI2.

Adoption

Several open source DRI drivers have been written, including ones for ATI Mach64, ATI Rage128, ATI Radeon, 3dfx Voodoo3 through Voodoo5, Matrox G200 through G400, SiS 300-series, Intel i810 through i965, S3 Savage, VIA UniChrome graphics chipsets, and nouveau for Nvidia. Some graphics vendors have written closed-source DRI drivers, including ATI and Kyro.

The various versions of DRI have been implemented by various operating systems, amongst others by the Linux kernel, FreeBSD, NetBSD, OpenBSD, and OpenSolaris.

History

The project was started by Jens Owen and Kevin E. Martin from Precision Insight (funded by Silicon Graphics and Red Hat).[1][21] It was first made widely available as part of XFree86 4.0[1][22] and is now part of the X.Org Server. It is currently maintained by the free software community.

Work on DRI2 started at the 2007 X Developers' Summit from a Kristian Høgsberg's proposal.[23][24] Høgsberg himself wrote the new DRI2 extension and the modifications to Mesa and GLX.[25] In March 2008 DRI2 was mostly done,[26][27][28] but it couldn't make into X.Org Server version 1.5[13] and had to wait until version 1.6 from February 2009.[29] The DRI2 extension was officially included in the X11R7.5 release of October 2009.[30] The first public version of the DRI2 protocol (2.0) was announced in April 2009.[31] Since then there has been several revisions, being the most recent the version 2.8 from July 2012.[4]

Due to several limitations of DRI2, a new extension called DRI-Next was proposed by Keith Packard and Eric Anholt at the X.Org Developer's Conference 2012.[14] The extension was proposed again as DRI3000 at Linux.conf.au 2013.[15][16] DRI3 and Present extensions were developed during 2013 and merged into the X.Org Server 1.15 release from December 2013.[32][33] The first and only version of the DRI3 protocol (1.0) was released in November 2013.[5]

See also

References

  1. 1 2 3 Owen, Jens. "The DRI project history". DRI project wiki. Retrieved 16 April 2016.
  2. 1 2 3 Mesa DRI License / Copyright Information - The Mesa 3D Graphics Library
  3. 1 2 3 4 5 6 Høgsberg, Kristian (4 September 2008). "The DRI2 Extension - Version 2.0". X.Org. Retrieved 29 May 2016.
  4. 1 2 Airlie, Dave (11 July 2012). "[ANNOUNCE] dri2proto 2.8". xorg-announce (Mailing list).
  5. 1 2 3 Packard, Keith (1 November 2013). "[ANNOUNCE] dri3proto 1.0". xorg-announce (Mailing list).
  6. 1 2 "Mesa 3D and Direct Rendering Infrastructure wiki". Retrieved 15 July 2014.
  7. Martin, Kevin E.; Faith, Rickard E.; Owen, Jens; Akin, Allen (11 May 1999). "Direct Rendering Infrastructure, Low-Level Design Document". Retrieved 18 May 2016.
  8. Owen, Jens; Martin, Kevin (11 May 1999). "DRI Extension for supporting Direct Rendering - Protocol Specification". Retrieved 18 May 2016.
  9. Faith, Rickard E. (11 May 1999). "The Direct Rendering Manager: Kernel Support for the Direct Rendering Infrastructure". Retrieved 18 May 2016.
  10. 1 2 3 4 5 6 Packard, Keith (21 July 2008). "X output status july 2008". Retrieved 26 May 2016.
  11. 1 2 3 4 5 6 7 Packard, Keith (24 April 2009). "Sharpening the Intel Driver Focus". Retrieved 26 May 2016.
  12. 1 2 Høgsberg, Kristian (8 August 2007). "Redirected direct rendering". Retrieved 25 May 2016.
  13. 1 2 Høgsberg, Kristian (4 August 2008). "Backing out DRI2 from server 1.5". xorg (Mailing list).
  14. 1 2 3 4 5 6 7 8 9 10 11 12 Packard, Keith (28 September 2012). "Thoughts about DRI.Next". Retrieved 26 May 2016.
  15. 1 2 3 4 5 6 7 8 9 10 Willis, Nathan (11 February 2013). "LCA: The X-men speak". LWN.net. Retrieved 26 May 2016.
  16. 1 2 3 Packard, Keith (19 February 2013). "DRI3000 — Even Better Direct Rendering". Retrieved 26 May 2016.
  17. 1 2 3 4 5 6 Packard, Keith (4 June 2013). "Completing the DRI3 Extension". Retrieved 31 May 2016.
  18. 1 2 3 4 5 6 7 8 9 10 Edge, Jake (9 October 2013). "DRI3 and Present". LWN.net. Retrieved 26 May 2016.
  19. 1 2 3 Packard, Keith (4 June 2013). "The DRI3 Extension - Version 1.0". Retrieved 30 May 2016.
  20. 1 2 3 4 Packard, Keith (6 June 2013). "The Present Extension - Version 1.0". Retrieved 1 June 2016.
  21. Owen, Jens; Martin, Kevin E. (15 September 1998). "A Multipipe Direct Rendering Architecture for 3D". Retrieved 16 April 2016.
  22. "Release Notes for XFree86 4.0". XFree86 Project. 7 March 2000. Retrieved 16 April 2016.
  23. "X Developers' Summit 2007 - Notes". X.Org. Retrieved 7 March 2016.
  24. Høgsberg, Kristian (3 October 2007). "DRI2 Design Wiki Page". xorg (Mailing list).
  25. Høgsberg, Kristian (4 February 2008). "Plans for merging DRI2 work". xorg (Mailing list).
  26. Høgsberg, Kristian (15 February 2008). "DRI2 committed". xorg (Mailing list).
  27. Høgsberg, Kristian (31 March 2008). "DRI2 direct rendering". xorg (Mailing list).
  28. Høgsberg, Kristian (31 March 2008). "DRI2 Direct Rendering". Retrieved 20 April 2016.
  29. "Server 1.6 branch". X.org. Retrieved 7 February 2015.
  30. "Release Notes for X11R7.5". X.Org. Retrieved 20 April 2016.
  31. Høgsberg, Kristian (20 April 2009). "[ANNOUNCE] dri2proto 2.0". xorg-announce (Mailing list).
  32. Packard, Keith. "[ANNOUNCE] xorg-server 1.14.99.901". X.org. Retrieved 9 February 2015.
  33. Larabel, Michael. "X.Org Server 1.15 Release Has Several New Features". Phoronix. Retrieved 9 February 2015.
This article is issued from Wikipedia. The text is licensed under Creative Commons - Attribution - Sharealike. Additional terms may apply for the media files.