September 4, 2007

Nouveau project hacks away at free Nvidia drivers

Author: Bruce Byfield

Currently, GNU/Linux users with Nvidia graphics cards have two choices: Either use the proprietary drivers and violate their free software principles, or use the free nv driver and do without 3-D acceleration. The Nouveau project is working to overcome this dilemma by producing its own set of fully functional free Nvidia drivers. We talked to Stephane Marchesin and Ben Skeggs, two of the active developers in Nouveau, about the history of the project and the current status of its work.

Like several others working on video drivers, both Marchesin and Skeggs got their start in the field in the R300 project, a discontinued project whose members attempted to understand 3-D acceleration on a family of ATI Radeon cards. Skeggs worked largely on fragment shaders, a graphics function that calculates and renders effects pixel by pixel, but says that, at the time, "I really had no idea how all the various bits of a full graphics driver fit together." By contrast, Marchesin was more deeply involved, reverse-engineering Hyperz, a processing technique that improved rendering speed, and tiling, a standard rendering technique, as well as porting 3-D functionality to the Itanium platform. "It was surely fun to see the Quake 3 frame rate go up as changes were made," Marchesin recalls.

Marchesin started working on Nouveau as a private project in June 2005. For nearly eight months, Marchesin worked on cleaning up the nv driver, and writing REnouveau, a reverse engineering tool for collecting information while the proprietary Nvidia drivers are running on a machine. "A lot of time was also spent understanding the inner workings of Nvidia cards, which are quite different from anything else in the graphics hardware field," he says. "The project was mainly motivated by my interest in low-level programming. That, and not being able to fix the binary Nvidia driver on my at-the-time work machine (either the drivers didn't like my chipset, or it was buggy. In any case a workaround was not possible due to the binary nature of the Nvidia drivers)."

In February 2006, Marchesin announced the project at the Free and Open Source Software Developer's European Meeting (FOSDEM). Skeggs' interest was sparked after he spent a couple of hours using REnouveau to learn about rendering on one line of Nvidia chips. He joined the #nouveau IC channel, he says, "with the intention of handing over what I'd learned and leaving it at that. Somehow, I ended up sticking around."

Nouveau's 2-D functions are a fork of the nv driver. However, according to Skeggs, "the code has changed quite a bit. We've had to move a sizeable amount of code into the kernel module, and rewrite significant portions of the engine setup in order to support multiple clients accessing the card at the same time."

At this point, much of the 2-D work is finished, and, according to Marchesin, "For day to day use, nouveau could pretty much replace nv now, both feature-wise and performance-wise." And, in fact, the nouveau driver has been included in several distributions, including Fedora 7 -- although, due to some limits in functionality, Fedora chose not to use it by default.

Currently, 3-D features are less advanced. "We only have basic working 3-D on a number of NV4x chips. Aside from getting the other chipsets up to speed, we need to implement texturing in the 3-D driver. As you can imagine, a 3-D driver lacking texturing isn't terribly useful!" However, he adds that the project has the basic knowledge to implement 3-D features -- it simply needs to write and test the code.

Work methods

For the rest of the intended features, work continues. Most of the work involves reverse engineering, often using such tools as REnouveau, and a Valgrind plugin for 2-D work.

The project also uses MmioTrace, a tool specifically designed for reverse-engineering video cards, which traces memory-mapped I/O access within the kernel. "Nvidia actually does most of the hard work in its kernel module," Skeggs explains, "and, at the beginning of Nouveau, there wasn't any tools available that'd allow us to see what happened inside Nvidia.ko. Without a tool like MmioTrace, we'd likely not be as far as we are currently."

In addition, Nouveau also pools information with other projects working with Nvidia cards, such as Utah-GLX and NVClock. The project is also sharing information with programmers working to develop drivers for Nvidia cards for Haiku, the BeOS-descended operating system. However, Marchesin says, "The existing 3-D-enabled drivers only work on older cards; for new cards, no information is available."

For other parts of the project, the teams' previous experience with free graphics drivers has been invaluable. "We've been making a number of global design choices motivated by both the Nvidia hardware design and our previous experience in the free software graphics diver field," Marchesin says. "As far as I know, we were the first free software driver to require the use of a kernel module even for basic 2-D. This helps us moving more parts of the code to the kernel, which in turn makes sharing the card between multiple applications more efficient."

Nouveau was approached by the Free Software Foundation, which asked whether its members wanted to be listed as a high-priority project, a move that helped to raise the profile of such projects as Gnash, the free Flash replacement, and LinuxBIOS. However, according to Skeggs, "We turned down the offer mainly to avoid too much attention, as Nouveau's still very much a developer's project, and not something that users would find too useful." Of course, Marchesin adds, "We got Slashdotted shortly after ..."

One source that Nouveau has not received any information from is Nvidia itself. Early in the project, Skeggs did ask Nvidia for documentation to enable multiple display support, "but was met with a reply that no documentation is currently available -- which is better than completely ignoring the request, I guess."

Nor is any future help from Nvidia likely. In an interview with ABCLinuxU, a Czech Web site, Andy Ritger, Nvidia's director of Unix software, is quoted as saying, "Nvidia's stance is to neither help nor hinder Nouveau." Ritger adds that Nvidia's GNU/Linux support will continue to be limited to the nv driver and the existing proprietary drivers.

However, this lack of support from Nvidia doesn't disturb Marchesin. "We have to show that it is possible to write a driver without vendor help," he says. "Through this project I'm trying to make that point."

Helping out and looking ahead

Nouveau remains a developer's project, but Skeggs says that average users can help the project by running REnouveau and MmioTrace on their own machines and submitting the output. Although Nouveau already has considerable information from a variety of cards, Skeggs says that "even between chipsets of the same card family, things can differ slightly."

Marchesin adds, "We're always looking for new developers. If you have some fair programming skills and are interested in learning graphics driver programming, our IRC channel is a friendly place, and just sitting there idling could bring most of the needed information [to you]."

Ultimately, Nouveau's goal, Skeggs says, "is to provide functional open source 2-D/3-D drivers for Nvidia chips from NV04 onwards."

And once that goal is reached? "Well, there's always things to improve [and] bugs to fix," Skeggs says. "Aside from that, I'm sure Nvidia will keep pumping out new chips for us to play with."

"I also expect people will benchmark our driver against the binary one," Marchesin says. "Which means we'll have to focus more on the performance aspects of the driver." Meanwhile, an army of potential users is waiting.


  • Graphics & Multimedia
  • Desktop Hardware
Click Here!