Ubuntu / Linux news and application reviews.

If you hear the term Direct2D, you are probably thinking of some outdated technology that preceded the Direct3D. That, however, is not true; Direct2D has only been introduced recently with Windows 7 and Server 2008. Although made by Microsoft, the Linux alternative shares the same name (well, almost; officially, it's Direct2DAccel). And yes, this is for X - not for Wine or anything like that.

What does Direct2DAccel do?

D2D enables graphic cards to do what we always wanted them to do – perform graphic tasks. Unless you are playing video games (probably not so much if you are using Linux), your graphic card's processor (GPU) doesn't do a whole lot – even when you are playing movies. That all made sense in the beginning, when GPU's power was 75-150 MHz. However, the GPUs nowadays are capable of running much faster than that and they hunger for jobs.

Direct2D seeks to eliminate dependency on CPU and transfer it to the GPU. For example, DirectDraw instructs mostly the CPU to draw windows, frames, play videos etc. The processors have always been strong enough to do all those tasks, but why buy a fast GPU if it does nothing?

I have personally tested Direct2D rendering on my machine and it is fabulous! Since it is still in experimental stage, there are some bugs that need to be fixed, but the progress has been huge (the last time I tested it little over 20 days ago it was virtually unusable). Drawing windows is much faster and Compiz runs smoother (there is no longer a 0.5 second lag when maximizing/minimizing your window that many ATI owners experienced).

How to enable Direct2DAccel?

First, let me make you aware of my testing environment:
  • Ubuntu 10.04 Lucid Lynx (latest updates)
  • ATI HD5750
  • FGLRX 8.723.1-0ubuntu2 (available from repos)
  • OpenGL on and direct rendering is on

To enable Direct2DAccel, go to terminal and type:
sudo aticonfig --set-pcs-str=DDX,Direct2DAccel,TRUE

Then restart X.

If something goes wrong, here's the way to revert it:
sudo aticonfig --del-pcs-key=DDX,Direct2DAccel

Now as I said, there are still bugs that need to be addressed, as well as functions that need to be implemented. The most notable one is that video does not play well or at all. However, there is a workaround for this:

First, load some video in Totem player or VLC or whatever you use - maybe it will work just fine. If not:

For Gstreamer based players (Totem e.g.)

In a terminal, type:

Then click on Video tab, under Default Output select the one that says "X Window System (No Xv)". Then see if it works.

If you are using VLC:

Go to Tools > Preferences > Video, and under output, select “X11 Video Output (XCB)” or “GLX Video Output (XCB)” (test both and see which one performs the best for you).

Selecting the “Without Xv” instructs the system NOT to use graphic card for rendering video which defies the purpose of Direct2D; BUT, as I mentioned, D2D is still highly experimental and not all features are implemented. If you have a good CPU then this shouldn't be an issue (I have quad-core Phenom II ). I don't know if weaker CPUs will have problems playing videos - they shouldn't, but please let me know in comments!

I averaged about 20% CPU usage while watching a DVD movie in Totem. I have no HD movies here at the moment so I'd be curious to see how they perform.

In any case, at this pace, we should have a fully functional D2D acceleration by the time the Ubuntu 10.04 Lucid final release comes out!

This is a guest post by Deusdies (thank you very much!)