My own little DirectX FAQ


Friday, August 23, 2002
What TextureStateState stuff can different cards do?

It's a difficult question to answer fully. Drivers change, bugs get fixed (or created!), etc. The short answer is "use ValidateDevice()". The longer answer is "know roughly what most cards do, know what the gotchas are, write multiple versions of your TSS shaders, and use ValidateDevice()". The addendum is "sometimes ValidateDevice() lies". For StarTopia, I ended up just having a huge list of cards, identified by DeviceID, with various messages to the game telling them which things the card did wrong. Sometimes cards had sections on various driver versions, because older drivers got more stuff wrong. Note that this file did not tell the game which TSS setup to use - that is driven by ValidateDevice(). What it does say is when ValidateDevice() gets it wrong, which is a lot less info to gather on all known cards.

Naturally cards released after the game is will have unknown DeviceIDs, so you need sensible defaults. So far StarTopia has done sensible and fast things on all of them, which is fairly pleasing.

Anyway, to be able to code a sensible set of three or four TSS setups, you need to know roughly what the different cards can and can't do. Here's a brief summary of what I know. Note that most of my intensive card-testing experience was done just before the ship date of StarTopia, so mainly around June 2001. This means a lot of this material may be out of date. So watch yourselves. The newer fancier cards have obviously been tested more recently, though mainly with pixel shaders rather than big TSS blends. The basic two and three stage TSS blends seem to work on all the pixel shader cards, which is what you expect.

Any IHVs reading - feel free to correct or expand any of this info - I'll keep it updated.


-Single-texture cards - a real mixed bag. All sorts of limitations and legacy nastiness. Mal Lansell has good info on most of these, and this covers most of what I know as well.

-Rage 128 - see Mal's post above. Older drivers have trouble with TFACTOR (see below), now fixed.

-Radeon 1,7x00: Three-stage TSS implementation. Supports TEMP and triadic blends. Everything seems to work, no suprises. Older drivers have trouble with TFACTOR (see below), now fixed.

-Radeon 8x00: PS1.4, but also exposes a 6-texture TSS implementation with TEMP and triadics. I haven't tried more than about four stages (anything more and I start to use pixel shaders instead), but so far no suprises.

-Radeon 9x00: haven't tried one yet. Unlikely to be any gotchas when using TSS, seeing as it exposes PS2.0.

-TNT1,2,Ultra,etc - see Mal's post above.

-GeForce 1,2,4MX,4Go: basically two general-purpose TSS stages. Aditional first stage can do SELECTARG1(TEXTURE) as well. Additional last stage can sometimes do MODULATE(CURRENT,DIFFUSE), though it seems temperamental whether it will let you or not. Always check with ValidateDevice(). Recent drivers expose triadic blends and TEMP register, but I've not played with that aspect yet. They also have the "8-stage blend" hack that drives the register combiners directly rather than using the TSS model - you'll need to contact nVidia devrel for more info. Drivers have trouble with TFACTOR (see below).

-GeForce 3,4Ti: PS1.1/1.3. Fairly sound 4 TSS stage implementation - not found any suprises yet, but again, if I'm doing anything complex, I usually go for pixel shaders, so the TSS stuff has not had a great deal of testing. Triadics and TEMP supported, and work. Drivers may have trouble with TFACTOR (see below).

-G4xx and G5xx series: Two-stage TSS implementation, though as mentioned recently on the list, ARG1 must be TEXTURE (and no triadics or TEMP). I vaguely remember vague vagueness of a third stage being available to do MODULATE(DIFFUSE,CURRENT), but people seem to have trouble getting it working.

-Parhelia: not played with one yet. Exposes PS1.3. I would expect a fully-featured 4-stage TSS implementation.

-PowerVR Kyro series: 8-stage TSS exposed. Yes, it really works. Not sure if triadics and/or TEMP are supported - from what I know of the hardware I don't _think_ so, but a PowerVR devrel person should rush to correct me if I'm wrong.

-3Dlabs P10: not played with one. Again, lots of pixel-shader goodness, so TSS implementations is probably fully-featured.


I don't know anything about any of the other chips.


The "trouble with TFACTOR" mentioned above is when doing multiple renders, and only updating the TFACTOR register between them, e.g. to change colour or opacity. A suprising number of drivers get this very wrong. Bugs seen:

-TFACTOR colour is effectively random. Presumably some timing problem, but I couldn't fix it in any sensible way.

-TFACTOR colour is the first-rendered thing. Subsequent changes are ignored, and everything gets rendered with the same colour.

-TFACTOR colour is the last-rendered thing. Everything gets rendered with the same colour.

-TFACTOR changes are ignored unless you change something else in the TSS pipeline (to force the driver to do a "rethink"). I usually found something simple like changing an alpha-channel blend from SELECTARG1(TEXTURE) to SELECTARG2(TEXTURE) or whatever.

This is the sort of annoying thing that needs testing for and overriding according to DeviceID and driver version - you can usually find a way to do things without TFACTOR, notably by using the D3DMATERIAL stuff. Changing material is fairly quick, and so far hasn't failed on any cards.


Hope that gives you a feel for the cards. When in doubt, always check with the IHV concerned. If you can't get a blend to work, they will usually be able to tell you the most efficient way to do the blend in a slightly different way, or give you the available options for multi-pass versions.