Very quick VertexBuffer question

Started by
11 comments, last by simon_brown75 11 years, 11 months ago
Thanks.

Well I've ammended the code so I'm now creating all my vertices in 5 vertex arrays (1 for each coloured font I have) in system memory, then once per frame I'm copying all those verts to the corresponding 5 VBs and rendering the fonts. So I now have just 5 lock()s and 5 calls to SetStreamSource/SetTexture/DrawPrimitive per frame. I'm also using DYNAMIC VBs in DEFAULT pool and using LOCK_DISCARD.

By doing all this it has just surpassed the old method by about 2%. If you take a look at my options menu above, using the old method of creating, filling, drawing from and destroying a VB for every text entry (there's 28 of them on that screen) I was getting 760 fps and using the new method where I'm not creating or destroying any VBs and just doing 5 locks per frame I'm now getting 780 fps.

It's a better piece of code now, and I guess any amount faster is a good thing, but I really expected more than that.

Oh well, it's not worth worrying about. The text drawing is only a tiny fraction of the time taken per frame while actual gameplay is happening. Time to move on.
Advertisement
The only major thing remaining to check is that you have D3DUSAGE_WRITEONLY on the buffers, but to be honest at this kind of framerate and considering the proportion of use of this code compared to the rest of your program, you're not going to see any really huge perf differences. The really important thing here is that you now have a batch of good dynamic buffer code that you can adapt/reuse for any other cases you have that may need it.

Direct3D has need of instancing, but we do not. We have plenty of glVertexAttrib calls.

Thanks very much for the help smile.png Yes the VBs are WRITEONLY.

TBH I should only be rebuilding the VBs when the text on screen changes, but I dunno if it's worth the effort to figure that out since there's greater potential for performance gains elsewhere in the code, and the text does change a lot during gameplay.

This topic is closed to new replies.

Advertisement