Some days as a programemr suck. Today is one such day.
All my old games use directx7, with my own engine,. Gratuitous Space Battles uses a new engine, directx9, and all is well.
In January this year, Kudos and Democracy stopped working for lots of people with the new nvidia drivers. They got crashes in the vertex buffer lock code. Obviously I hadn’t changed a thing. the games had worked fine on thousands of PC’s for years. Suddenly nvidia must have changed the way they handle vertex buffers under directx7. Thanks guys!
The old code was very old school and simple. I locked a vertex buffer, then copied in memory, then unlocked, and rendered from them. Big deal. I didn’t use any cleverness with the buffers gradually filling up and then discarding them. (I do that in GSB) I always locked the whole buffer and the lock flags always looked like this:
HRESULT hr = VertexBuffer->Lock(DDLOCK_WRITEONLY | DDLOCK_DISCARDCONTENTS | DDLOCK_SURFACEMEMORYPTR,
(VOID**)&BufferMem,&bufsize);
For every VB lock. I did a few of these each frame, mainly for rendering text. This may not be optimum, but it worked fine, all return codes checked ok on all cards and all drivers.
Suddenly, on my nvidia 8800 GTS, and for everyone else with new drivers (except the 9800 GT), this crashed, and would only work if changed to this:
HRESULT hr = VertexBuffer->Lock(DDLOCK_WAIT | DDLOCK_SURFACEMEMORYPTR,
(VOID**)&BufferMem,&bufsize);
In theory this is less efficient. But suddenly it works. Hurrah. Except not for 9088GT owners. I tried this:
HRESULT hr = VertexBuffer->Lock(DDLOCK_WAIT | DDLOCK_WRITEONLY | DDLOCK_SURFACEMEMORYPTR,
(VOID**)&BufferMem,&bufsize);
This also works on my 8800GTS, but even this does not work on the 9800GT. I can’t get a reply from nvidia, and the developer forums there hurl abuse and sarcasm at anyone who dares to ask about why a directx7 program won’t run (I’ve read a fair few threads there). Apparently we should all just STFU and re-code everything in DX10. Err right….
Anyway, I have nothing to say on this topic other than it depresses me. I don’t want to be fixing games I finished a few years ago, I want to work on new stuff…but obviously I need to support all my customers. I just wish someone at nvidia would tell me what they changed, and how to work around it for all their video cards. I emailed them a few days ago but got no reply…
If you work an nvidia, or know everything about directx7 VB usage with modern drivers, please shower me with your wisdom. And if you have an nvidia card, feel free to try the demo to Kudos 2 or Democracy 2. Both should now work, but I’d love to know if they don’t, what video card and driver you have…
bah :(