Skip to main content
gamedev.net
🔒 Locked

Vertex buffer performance

Started by Tom Apr 27, 2004 at 12:12 PM 3 replies 350+ views
Original Post
Tom
Tom
I have a program that renders up to several hundred sprites each frame across six different layers (with each layer representing a texture and corresponding vertex buffer). In my prototype, I was rendering each sprite with a separate DrawPrimitive call; very slow, but it got the job done. Now I need to optimize using vertex buffers. The largest number of sprites in a given vertex buffer will probably be about 1248 (absolute maximum). My sprites are being created an destroyed almost constantly. Do you think it''s reasonable to construct a fresh vertex buffer each frame (32ms = 0.03125s), or would you recommend updating my existing vertex buffers, rebuilding them only when sprites are added/removed? I wonder what kind of overhead there is for uploading new buffers to the video card every frame; that''s why I ask. I like to hear from someone with experience and advice in this sort of thing. Thanks in advance.
GDNet+. It's only $5 a month. You know you want it.
neneboricua19
neneboricua19
If you''re going to be creating and destroying info all the time, the best thing to do then is to create your vertex buffer with the DYNAMIC flag. This tells D3D that the contents of the vertex buffer will be changing constantly.

You don''t actually have to create and delete the vertex buffer every frame. Create your vertex buffer when your app starts and release it when your app finishes. Every frame, you Lock the vertex buffer and fill it with the data you need. When you Lock the vertex buffer, make sure you use the DISCARD flag.

Hope this helps,
neneboricua
Pipo DeClown
Pipo DeClown
Creating each frame = bad.
Updating each frame = bad, but hurts less.

Maybe you should use ID3DXSprite..

--
You''re Welcome,
Rick Wong

- sitting in his chair doing the most time-consuming thing..
Raloth
Raloth
ID3DXSprite = same thing as updating every frame

If done properly you can get up to 70% of the performance of static vertex buffers. 1248 sprites should be nothing for a video card to handle. Since you will be AGP limited, you should be able to throw in plenty of special effects with shaders (if your card supports them) for almost free.
____________________________________________________________AAAAA: American Association Against Adobe AcrobatYou know you hate PDFs...
Tom
Tom
Thanks for the info, guys. I''ll look into D3DXSprite before I make any decisions. If it''s no worse than clearing and filling a dynamic vertex buffer 190 times a second (before optimizations), maybe I''ll use it instead.
GDNet+. It's only $5 a month. You know you want it.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.