I've been playing around with some experimental new MDL rendering code in an older version of DirectQ, and the good news is that I can now get the 400 Knights map exceeding 200 FPS.
The bad news is that it needs hardware vertex buffers (with multiple streams - a form of instancing, really) and shaders, so it's not going to happen for a while yet. Another reason to drop the legacy paths from DirectQ!
RMQ already has a variation on this, but it's not as fast (and the code is nowhere near as clean - OpenGL VBOs suck for messy code). The main speed difference is that the D3D version can use dynamic vertex buffers, which I've never been able to get working satisfactorily in OpenGL.
So compare this with the heap of gl*Pointer/glBindBuffer/glEnableClientState/glClientActiveTexture/etc that OpenGL needs (how times change):
d3d_Device->SetVertexDeclaration (d3d_MdlVertDecl); d3d_Device->SetStreamSource (0, d3d_MdlVertBuffers[hdr->buffernum], 0, sizeof (mdlvert_t)); d3d_Device->SetStreamSource (1, d3d_MdlStBuffers[hdr->buffernum], 0, sizeof (mdlst_t)); d3d_Device->SetIndices (d3d_MdlIndexBuffers[hdr->buffernum]); d3d_Device->DrawIndexedPrimitive (D3DPT_TRIANGLELIST, 0, 0, hdr->numverts, 0, hdr->numindexes / 3);
A funny thing with this code is that it's actually slower under light loads - some overhead from vertex buffers (can't imagine what, but it's the only theory I have) must outweigh the gains from using them in those cases. Put it under pressure though, and it sings.
There are other nice things that RMQ does with vertex buffers that are going to be candidiates for migration back to D3D for DirectQ, but the RMQ codebase does also support legacy codepaths if the newer stuff isn't available, which is a necessary requirement, but does compromise it's performance (and code cleanliness) a little.
Anyway, I also got some work done on lightmaps in DirectQ, but lost a whole heap of performance from it, which was quite odd; especially as a previous version of the same (also D3D) was a huge gain in another test. I'm going to need to revert that, but overall the release is coming closer.
0 comments:
Post a Comment