[Mesa-dev] Direct3D 9 state tracker

Christoph Bumiller e0425955 at student.tuwien.ac.at
Tue Jul 16 12:43:56 PDT 2013

So, about two months ago I had the insane idea to pick up Joakim
Sindholt's Direct3D 9 state tracker that he'd started about 3 years ago
with the goal to make it run StarCraft 2 so I could finally play at a
reasonable frame rate ...

With help from Joakim and advice from the wine developers, as well as
wine's d3d9 tests, things went surprisingly smooth and my original goal
has been achieved and surpassed, hence I thought I'd post a note here in
case someone who doesn't yet know about it is interested in trying it out.

... Now wait, didn't we have a D3D10/11 state tracker already that we
kicked out because it was unmaintained and not really useful ?
Yes, but there are a couple of differences to d3d1x:

- the original author has not vanished [yet] (Luca, if you can hear me:
You cannot leave your children out to die like that !)
- it's written in C instead of C++ and not relying on horrific multiple
inheritance with templates hacks to make gcc generate COM-compatible
vtables (and I'm still not sure if that actually worked)
- gallium wasn't ready for D3D11, and still isn't (at least the pipe
drivers aren't), but it is ready for D3D9, and all the features required
from the pipe drivers are well tested via OpenGL
- there are no motivating applications using Direct3D 10/11 yet (at
least for me)
- and most importantly, contrary to d3d1x, d3d9/st already actually
works for real applications !

So far I've tried Skyrim, Civilization 5, Anno 1404 and StarCraft 2 on
the nvc0 and r600g drivers, which work pretty well, at up to x2 the fps
I get with wined3d (NOTE: no thorough benchmarking done yet).
Civilization 4 works, too, but it still has a couple of (not too severe)
rendering issues because I didn't pay much attention to the fixed
function pipeline and its interaction with the earlier shader versions yet.

If people think it's a good idea to merge it, I'd clean up the few
modifications I did to gallium, and, once they've been cleared, merge
the state tracker itself.
Unfortunately, for proper window system integration, a few modifications
to wine are required (it used to run without them, but fully correct
operation isn't possible like that).

Here's the links to the mesa branch containing the state tracker and to
a patched version of wine:
(The wine modifications only affect { d3d9.dll.so, gdi32.dll.so,
user32.dll.so, wineps.drv.so and winex11.drv.so }, so you don't have to
replace all of it).

Some usage hints:

More information about the mesa-dev mailing list