Guide: Tweaking your graphics drivers under Linux

PV5150

New member
Hi Guys, thought it was time for another guide...I hope you find it useful in one way or another. :)

Disclaimer

SysXtreme forum and the Author, can in no way be held responsible for any damage to your system, by using this guide. This information and the software included here-in are 'as is, where is' (meaning no recourse of action). This is by no means intended to put you off trying this guide, just remember, you're on your own if you damage something.

Background

Back when Linux was a fledgling OS, games weren't exactly a priority for the new platform. Over a decade later, this remains the same - or does it? Popular perception is that Linux is not a gaming platform, and certainly mainstrem support for it from game developers is limited. However when it works, it's awesome. Linux provides speed, stability and oodles of features, but before game developers can do their thing, the platform needs stable and fast drivers for 3D hardware. It's been a while coming, but 3D support under Linux is now finally becoming mature. So much so, in fact, that the 'Big Two' of Nvidia and ATI provide almost the same functionality for their cards under Linux as they do under Windows. So this guide is all about making the most of your graphics drivers under Linux, and how to tweak them well.

Nvidia

Older graphics cards (pre-GeForce FX) require a tool called nvclock, while current cards can use the control panel bundled with the drivers (covered below). For nvclock grab the 0.8 beta source code, extract it out and use the usual build process:



tar zxvf nvclock0.8b.tar.gz

cd nvclock0.8b

./configure

make && sudo make install


This will build the nvclock command-line tool, as well as GUI versions (nvclock_qt or nvclock_gtk) if you have GTK or QT development packages installed. The GUI's are quite easy to use - just remember to run them as root - but the command-line tool is handy when you have to SSH in from another system because you've clocked a little too high and trashed your display. Run 'nvclock -l' to get the current speeds, and 'sudo nvclock -r' to reset the card to it's defaults. Use the '-n' and '-m' options to set the clock speed of your core and RAM respectively.

sudo nvclock -n 480 -m 550

On more recent Nvidia cards, nvclock doesn't work as expected because the driver automatically clocks cards up and down when switching between 2D and 3D modes, overwriting your own tinkering. The 'official' way to do things now is through the driver itself, which since version 1.0-7664 has Coolbits support, just like the Windows drivers. To enable Coolbits, edit your X config file (typically /etc/X11/xorg.conf) and find the 'Device' section for your card. Add the following line:

Option "Coolbits" "1"



Then run the 'nvidia settings' tool that gets installed alongside the drivers - you might already be familiar with this. The NVIDIA settings tool lets you tweak all sorts of driver options, and adding the Coolbits option to your X config enables a new 'Clock Frequencies' tab. If you're lazy, you can hit the 'Auto Detect' button and have the app automatically determine a safe overclock for you, but it tends to be a bit conservative so you'll probably want to do some manual tweaking afterwards (of course you do :D ). If you prefer, you can also use nvclock to do your tweaking; it can't set the clocks directly, but it now supports setting them through Coolbits, just like the Nvidia settings tool. Nvidia-settings can change your clock speed from the command-line too; it has options that let you specify values for all sorts of tweakable attributes, including clock speeds. Run 'nvidia-settings -q all to get a list of all the available attributes and their values. To set the clocks, try something like this:

nvidia-settings -a

GPU3DClockFreqs=510,550


ATI

For overclocking ATI cards, you'll need rovclock, which should support all RADEON models. Grab the latest tarball, extract, and build:

tar jxvf rovclock-0.6c.tar.bz2

cd rovclock-0.6c

make

sudo cp rovclock /usr/local/bin


rovclock is a simple command-line affair; there's no pretty GUI at all, but it still does the job quite nicely. Run 'sudo rovclock -l' to get the current speeds. If they don't match what you'd expect for your card, try adding '-x 1432' or '-x 2950' to the command line. To set the core and RAM clocks, use the '-c' and '-m' flags respectively.

sudo rovclock -c 450 -m 550

# One thing that you might notice when using rovclock is that sometimes it doesn't work as expected if you try specifying only the '-c' or '-m' options, rather than using both. You can still vary them one-at-a-time, but make sure that you do set a value for each of them every time you run rovclock

Regardless of which tool you need to use, you'll probably want your overclock of choice kicking in automatically on boot, rather than having to set it manually all the time. You can actually do it at boot in an initscript, but you'll probably find that the video driver resets the clocks when starting X; it's a common ploy to have cards boot at lower speeds than usual, with the driver clocking them up to proper levels. Because of this, you really need to set the clocks during your desktop environment startup, after X has started. On a GNOME desktop, you can add a program to your desktop startup by opening the Sessions settings. Go to the Startup Programs tab, click on Add and enter in the command to run. Under KDE, you'll need to put the command in to a short shell script, and place that in your ~/.kde/Autostart/ directory. Your script will need to be something like this:

#!/bin/sh

sudo rovclock -c 450 -m 550


As long as it's in that folder, and marked as executable (chmod +x), you can call the file whatever you like. If you're not using KDE or GNOME, you're probably using a custom .xinitrc or .xsession file - just add the command to that. Easy!!!

Unless you're using Coolbits overclocking, the tricky part comes when you realise that you just told your desktop to run a command with 'sudo' at startup, and it's going to ask for that password of yours to succeed. Even worse, if you happen to have used sudo within the last few minutes, it might just work, making it one of those incredibly fun problems that magically goes away once in a while. The solution is to configure sudo to let your user account run the overclocking tool without needing a password. Edit your /etc/sudoers file (using 'sudo visudo' - never edit it directly) and look for the line that lists your user and its privileges: there might be an entry under your username, or one for a group (such as 'admin' or 'wheel') that you've been added to. Edit this line and add 'NOPASSWD:', followed by the full path to your overclocking tool. It should look like this:

%admin ALL=(ALL) ALL NOPASSWD:

/usr/local/bin/rovclock


Alternatively, if it's your personal box and you're not too worried about people coming along and doing obscene things to it, you can tell sudo to let you run anything as root without a password:

%admin ALL=(ALL) NOPASSWD: ALL

FSAA

Full screen anti-aliasing is something that we tend to take for granted these days. On Nvidia cards, you can turn on FSAA on a per application basis by setting the '__GL_FSAA_MODE' environment variable, and then running your application from the same terminal window:

export__GL_FSAA_MODE=4

ut2004
(hehe joke Jim Kemp and Dave :D )

The values that __GL_FSAA_MODE takes are just simple integers that enable different settings depending on the card; the value of 4 I have set here enables bilinear multisampling on GeForce FX or later cards. The official Nvidia driver README has tables listing the valid values and the settings they correspond to for each type of card. You can similarly enable anisotropic filtering by setting the '__GL_LOG_MAX_ANISO' environment variable: 0 disables it, while 1, 2, 3, or 4 enables 2x, 4x, 8x, and 16x respectively, though only 6800 and higher cards go all the way up to 16x.

On ATI hardware, FSAA is more cumbersome to use because it's configured from the Xorg configuration file, rather than on-the-fly like the Nvidia drivers. Open your /etc/X11/xorg.conf file, skip through to the 'Device' section for your ATI card, and set the following options:

Option "FSAAEnable" "yes"

Option "FSAAScale" "4"

Option "EnablePrivateBackZ" "yes"


Unfortunatley having these options enabled is still no guarantee that FSAA will work. Certain models, including the RADEON 9600 variants (and the 9550) simply refuse to enable FSAA, reporting this in the /var/log/Xorg.0.log file:

(==) fgirx(0): FSAA enabled: NO

If you find this in your logs, there's probably very little you can do about it - ATI have known about the problem for a while, but there's no fix yet. There is a community driven Bugzilla setup for the ATI drivers available at ati.cchtml.com that tracks the status of problems like these.

Multihead Support

Xorg has supported spanning a desktop across multiple displays since the Xfree86 4.0 days, but due to issues in the generic Xinerama extension, both ATI and Nvidia have added special support for dual-head cards into their drivers. These skip X's multi-monitor configuration and build what looks to X like a single large display, enabling features like multi-head 3D that otherwise wouldn't work. Nvidia's TwinView is configured through options in the Device section for your card.

Option "TwinView" "true"

Option "TwinViewOrientation"

"RightOf"

Option "SecondMonitorHorizSync"

"31.3-75"

Option "SecondMonitorVertRefresh"

"60-100"

Option "MetaModes" "1280x1024,

1280x1024"


These options describe the capabilities of the second monitor, and it's position on your desk relative to the primary monitor. The MetaModes option describes the screen modes to use on the two heads of your card - here I'm using 1280 x 1024 on both. You can add extra sets of resolutions by adding them with semicolons. On ATI harware, the options are similar, but simpler:

Option "DesktopSetup" "Horizontal"

Option "HSync2" "31.5-75"

Option "VRefresh2" "60-100"




Image courtesy of Phoronix, it's a wealth of knowledge on Linux gaming. Check 'em out
http://www.phoronix.com/

The desktop option describes how the two screens are positioned; if you want to stack one on top of the other, specify 'Vertical' here instead. If the monitors are the wrong way around, add 'Reverse' to the option value. You can also tweak these options through the control app (fireglcontrolpanel). To disable dual-head, change DesktopSetup back to 'Single', or just comment it out. So now that the driver is set up for speed and style, we only need more developers to come to the party.

Quake 4 under GNU Linux = Sexy. Thanks to softpedia for the Quake 4 screeny :yumyum:



Enjoy

PV :)

Picture Sources

www.softpedia.com

www.phoronix.com

 
Back
Top