Beyond Eye Candy
Total Page:16
File Type:pdf, Size:1020Kb
COVER STORY Xgl and Compiz An OpenGL-accelerated desktop with Xgl and Compiz BEYOND EYE CANDY www.sxc.hu A member of Suse’s X11 team delivers an insider’s look at Xgl. agement must work hand in hand, we can expect to see more compositing BY MATTHIAS HOPF window managers in the future with the ability to merge both processes. ac fans were ecstatic when The Render extension adds new basic Another important X server compo- Apple introduced the Quartz primitives for displaying images and nent that desperately needs reworking is MExtreme [1] graphics interface, polygons, along with a new glyph sys- the hardware acceleration architecture, which accelerated desktop effects using tem for enhanced font displays. This which is responsible for efficient hard- 3D hardware. Microsoft’s Windows Vista particularly reflects the fact that the leg- ware representation of graphic com- with its Aero technology looks to close acy graphics commands, called core re- mands. The previous XAA architecture is this gap with the Mac. In the world of quests, no longer meet the demands built around core requests, and is there- Linux, Xgl [2] now provides a compara- placed on modern toolkits such as Qt fore difficult to extend. The architecture ble and even more advanced technology and GTK. All primitives can now be outlived its usefulness and needs replac- that supports similar effects. linked to data in the framebuffer using ing. The most promising alternatives are Xgl is an X Server by David Revemann Porter-Duff operators [3], thus support- EXA and OpenGL. that uses OpenGL to implement graphics ing the rendering of semitransparent sur- EXA is straightforward and easy to im- output. When a program tells Xgl to faces (alpha blending) and fonts with plement, but OpenGL has the advantage draw a line, Xgl passes the vertices to anti-aliasing (pixel coverage). Many of being a widespread programming in- the OpenGL subsystem, which then modern applications make extensive use terface supported by working drivers. sends the matching commands to the of antialiased fonts in particular. There is no need for the X server to con- graphics hardware. Despite this empha- Up to now, the window system used in trol the hardware. In the future, there sis on OpenGL, Xgl also retains the pro- X has supported overlapping windows, will only be one graphics hardware in- tocol that existing applications use to but it has not provided the ability to terface, rather that two separate inter- talk to the X Server, removing the need draw to invisible window areas and dis- faces for XAA/ EXA and OpenGL. to rewrite application programs. play this window content. To achieve this, all windows first have to be drawn Looking Deeper Background in an invisible area of the framebuffer, In constrast to popular claims, Xgl does Following an extended period of stand- before all windows are joined (compos- not accelerate the execution of OpenGL still in X server development, program- ited) in the visible frame buffer. This is programs. On the contrary, only indirect mers have integrated new features in re- exactly what the X server’s Composite rendering is possible for technical rea- cent years to provide a basis for the new extension does. sons at this time of writing. In other Xgl technology. Modern toolkits such as An external process handles the task words, OpenGL commands are handed Qt and GTK already use many of these of combining all the windows to provide to Xgl via the GLX protocol before being new features without users actually real- an overall view in a similar way to the passed on to the graphics hardware. In- izing it. Two major protocol extensions, well-known window manager. It can use direct rendering is much slower than di- Render and Composite, play an impor- the Render extension to draw multiple rect rendering for programs that need to tant role for Xgl and the composite man- superimposed, semi-transparent win- generate large numbers of polygons ager Compiz. dows. As compositing and window man- (games) or textures (video). 24 ISSUE 68 JULY 2006 WWW.LINUX - MAGAZINE.COM Xgl and Compiz COVER STORY ager that can use OpenGL commands to Application(s) Composite Manager display windows. This option is not X11 Protocol EXT_texture_from_pixmap GLX Protocol open to the normal X Server, as OpenGL is not linked to the underlying window system; that is, it cannot access window Xserver content drawn using X11 commands. DDX Mesa / GLX As Xgl uses OpenGL internally, it can make window content accessible to an Pixmap Buffer ID 3D Desktop Geometry external composite manager using the Glitz GLX_EXT_texture_from_pixmap exten- sion. This extension is not provided by the OpenGL driver, but by Xgl. X.org has included this extension since the imple- OpenGL mentation of AIGLX, but it is still miss- Commands from XGL Texture Binding Commands from ing support for a number of features. Composite Manager As previously mentioned, the compos- pBuffer / FBO ite manager uses indirect rendering to gfx Hardware draw the desktop; that is, all OpenGL commands are sent to Xgl using the GLX pBuffer / FBO protocol before being passed to the graphics hardware. This is the only way pBuffer / FBO Framebuffer for another process to use textures in the Xgl address scope. This issue also affects Figure 1: Pixel pipeline of a composite managers under Xgl. all OpenGL applications, as they have to draw in an invisible area of the frame- At the current time, Xgl cannot na- and rendered by OpenGL. This process buffer, which has to be in the X server tively access the hardware; instead it occurs separately for each program. address scope as well. Refer to [4]. relies on a system that initializes the Then the composite manager draws the framebuffer and provides an OpenGL window content as textures on OpenGL Compiz interface. Right now, that is the popular objects. The objects are typically rectan- Humans are accustomed to understand- Xorg X Server; in other words, Xgl opens gles, but they can be more complex, ing three-dimensional scenarios. It thus a window that covers the whole screen three dimensional objects for transitions. makes sense to project the GUI onto a on the Xorg server. After this has hap- Therefore, Xgl is not responsible itself three dimensional desktop, assuming the pened, X applications can connect to for the breathtaking effects we have interactions with non-two-dimensional Xgl, while the standard X server only has heard so much of, however, it does allow program representations are kept to a to deal with the Xgl client throughout programmers to create a composite man- minimum. Genuine 3D interaction still the whole session. The X11 commands the server has to handle can be fairly complex; this is why an abstraction layer is used to encapsu- late the OpenGL statements. The layer, in the form of the Glitz library, is basi- cally the OpenGL-accelerated back-end for the Cairo library, a system for graph- ics operations that works independently of the resolution. When a composite manager enters the array, more complexity is added to the graphics pipeline. As Figure 1 shows, the X Server first redirects all window output to non-visible areas of the framebuffer. A memory area of this kind is created by a pBuffer or Frame Buffer Object (FBO). All X11 commands issued by an applica- tion are redirected to this memory space Figure 2: Compiz toggling to another virtual desktop. WWW.LINUX - MAGAZINE.COM ISSUE 68 JULY 2006 25 COVER STORY Xgl and Compiz like to see the complete driver code ousted from the X server. An X server working on the basis of OpenGL could more easily support a future protocol that dropped core graphics primitive support to improve client-server commu- nications. One of Xgl’s major weaknesses is its lack of native hardware support. For the time being, it is forced to rely on the Xorg server as an intermediary. An ex- perimental branch dubbed Xegl is capa- ble of talking directly to the graphics hardware, although it is restricted to R100 and R200 based Radeon cards, and the current server status is unknown. Everyone involved seems to agree that the future belongs to OpenGL-based Figure 3: The Switcher plugin with live thumbnails of applications. compositing window managers. And Compiz in particular could be the win- poses a number of technical issues and easily modify Compiz to suit their own dow manager of the future thanks to its is typically unintuitive. taste. Check out [6] for a more detailed flexible plugin architecture. Projecting two-dimensional pixel data list of plugins, along with function de- As of this writing, Xgl and Compiz are onto three-dimensional objects is a stan- scriptions and instructions on how to both fairly stable, but they are at an dard application for OpenGL. At the use them. early stage of their development. Pack- same time, you get effects such as semi- OpenGL-based programs are often crit- ages are available for openSuse [5] to transparency more or less for free, as icized for being eye candy and nothing give users an opportunity to test the new they are part of OpenGL’s standard bag more. However, this technology really technology without going to much trou- of tricks. So far, the only reason not to does support useful developments in the ble. The current snaphots of the immi- release a composite manager of this kind field of accessibility aids for users with nent Ubuntu release, Dapper Drake, has been that Xgl was needed to open up sensory impairments (using a zoom plu- allow users to install Xgl and Compiz.