Monday, February 7, 2011

DirectQ Update - 7th February 2011

Been having some fun with software T&L cards, MDLs and entity alpha.

First up, hardware T&L is one of those things that you tend to take for granted until you're suddenly hit by a part that only does software. In this case it was an Intel 945 (Intel is weird in that it has a few parts that are fully DirectX 9 but only have software T&L). It turned out that the vertex buffer useage pattern I had built up for world surfaces was completely inappropriate for software T&L. First thing was that it crashed, but on further investigation I decided that - seeing as how randomly hopping around in a vertex buffer is bad for software T&L performance - to make some small changes. Now if you have software T&L it doesn't cache recently used surfaces, but just streams them out to the buffer always. It's not really a performance loss as the only performance gain from caching was to have these surfaces already in driver-optimal memory, which does not apply to software T&L.

Second thing was MDLs. It occurred to me that I could implement a form of vertex caching here too, where if the current frame hasn't changed there's no need to update the vertex buffer for an entity using that MDL. There are some nasty gotchas with this, in particular relating to lighting (an important component of lighting is derived from entity angles), and interpolation also means that the current frame tends to change every frame anyway (as it's really an interpolated position), but overall it's proven effective enough.

Entity alpha is a barrel of laughs. I based my original implementation on FitzQuake's (derived when I adapted the protocol) and was never happy with what looked like a mess to me. All the ENT_ALPHA_DECODE, ENT_ALPHA_ENCODE stuff - eeewww! Now, I know why it's done that way (so that a memset to 0 will be valid for fully opaque) but it still seems inelegant, and wasn't living nicely with Nehahra alpha (another world of pain) either. So I've ripped it apart and also fixed an omission in DirectQ where static entities didn't get alpha set.

In other news the dreaded PF_VarString crash is back. This generally occurs if you change a map or exit the game at the precise moment that QuakeC is sending a console or center print with a value in it. This seems to crop up at random intervals, even in a straight port of IDQuake to MSVC 2008, and was probably always there but I just hadn't triggered it for a while.

If anyone knows what the hell is going on with it (and of a fix) I'd appreciate the heads up.

0 comments: