Windows 8 takes three of the APIs introduced in Windows 7—Direct3D 11, DirectWrite, and Direct2D—and makes them even faster. Applications that use these APIs will be able to take advantage of some considerable performance improvements.
Direct2D is a 2D graphics API that is built on top of Direct3D, enabling it to take advantage of the powerful GPU hardware that is now a feature of every PC. It allows programmers to deal with 2D concepts—lines, rectangles, ellipses—and converts them behind the scenes into the fundamental 3D objects, points, lines, and triangles, so that the GPU can draw them.
For straight lines this is an easy process, but it's more complex for curves: lots of small line segments have to be generated to approximate the curve, a process called tessellation.
DirectWrite is an API for laying out text, and it can use Direct2D (or Windows' old GDI API) to handle the actual drawing of the text.
These APIs were both "version 1" in Windows 7, but even that first version provided good performance. Both Internet Explorer (since version 9) and Firefox (since version 4) have used Direct2D and DirectWrite, and their use of this technology is one of the reasons why their graphical performance is far better than that of their predecessors.
In Windows 8, Microsoft has worked to optimize various common usage scenarios involving these APIs. For example, DirectWrite and Direct2D are often used to show short runs of large text on things like headlines and subheadings, so Microsoft has made this scenario faster.
Similarly, Metro applications will contain a mix of simple geometry (lines and boxes) and more complex vector-based boxes, so Microsoft has improved the tessellation performance of such applications.
Giving the GPU more to do
Work has also been done to enhance Direct2D's performance of complex scenes. Although Windows 7's Direct2D uses Direct3D 10 to take advantage of GPU acceleration, an important part of the drawing process, called rasterization, is still handled by the CPU. Rasterization is one of the final steps in 3D drawing; it's the conversion of the vector-based lines, points, and triangles into a set of pixels on a grid.
Direct2D in Windows 7 handles this on the CPU because Direct2D needs very precise control over how this is done. In particular, it needs control over antialiasing. Without antialiasing, diagonal lines tend to look jagged and ugly, and text can be hard to read. While GPUs can do antialiasing of their own, their algorithms tend to be engineered toward 3D graphics and high performance. Direct2D has different needs.
Direct2D in Windows 8, however, uses Direct3D 11.1, which introduces a new hardware feature called Target Independent Rasterization (TIR). With suitable Direct3D 11.1 hardware, the rasterization and antialiasing step can now be performed by the GPU, avoiding the need to perform this task on the CPU.
Direct3D 11.1 also enables support for a feature that's found on some GPU hardware called Tile-Based Deferred-Rendering (TBDR). Traditionally, GPUs have been engineered for game-type graphics, where the whole screen (or at least, almost the whole screen) changes every frame. Imagine running around in a first-person shooter, for example; while your HUD might remain fixed in view, everything else you see will change because you're standing somewhere different in the 3D environment.
2D graphics, however, don't tend to work like that. Consider watching a video on YouTube; there's a box in the middle of the screen that needs to update 30 times a second, but everything surrounding that box is pretty static.
TBDR is designed to optimize this kind of scenario. With TBDR, the screen is divided into tiles, and each tile is drawn separately. This allows the GPU to skip redrawing those parts of the screen that haven't changed, such as the YouTube webpage, and only expend resources redrawing the parts of the screen that have changed, such as the YouTube video itself.
TBDR is found on lots of the low-power GPUs such as the PowerVR SGX family used in the iPhone and iPad, and the Mali GPU designed by ARM. Long ago, PowerVR made PC GPUs that were sold under the Kyro brand that used similar techniques. Because the technique enables the GPU to do less work, it offers both performance advantages and, perhaps more importantly, power savings.
Other graphics tweaks
Moving away from the GPU, but still in the graphics stack, Microsoft has improved the code used to compress and decompress JPEG and PNG images, to make better use of vector instruction sets provided by CPUs.
Just how much difference do these changes make? Microsoft says it can be substantial. In a blog post outlining some of the performance improvements, the company claims that text drawing can be between 31 and 236 percent faster, simple 2D graphics can be drawn between 84 and 338 percent faster, and complex graphics with TIR hardware can be between 51 and 423 percent faster (all comparisons are relative to Windows 7). The new JPEG and PNG routines can decompress and display pictures in about 60 percent of the time that they took in Windows 7.
Metro-style applications built using C++ or C# and XAML should also reap the rewards, as they should use Direct2D and DirectWrite for their drawing. But the extent to which this is true is less clear. In the Windows 8 Developer Preview, hardware acceleration appeared to be disabled for these applications. The extent to which it's enabled in the Release Preview is also unclear; Microsoft's Direct3D debugger, PIX, seems to crash when used with these applications, preventing any close examination of their GPU usage.
Then there's the desktop, the place where every existing Windows application resides. The news there is varied. Direct2D applications, including Internet Explorer and Office 2013 will be able to take advantage of all Microsoft's work.
But most desktop applications don't use Direct2D. Commercial ones, especially, use the old GDI API. Up until Windows Vista, this was extensively hardware accelerated. Windows 7 reinstated some of the acceleration that Windows Vista removed, but not all. Even when hardware accelerated, GDI doesn't take advantage of 3D hardware. Nor can it be easily changed to do so.
The applications that don't use GDI use Windows Presentation Foundation (WPF) and Silverlight (especially common among line-of-business applications). And while desktop applications using WPF and Silverlight do use Direct3D, at least to an extent, they don't use any of the new features introduced in Windows 8—or even Windows 7. Their GPU acceleration is all courtesy of Direct3D 9. This is a pity, since there were plenty of inefficiencies in the way they work.
Windows 8's graphical stack has plenty of performance to offer, for the right kind of application—but we're going to need to switch to a whole new set of Metro applications if we want to take advantage of it.