Archived

This topic is now archived and is closed to further replies.

Ilankt

should i use quads with drawprimitive for tiles?

Recommended Posts

because sprites dosent give me good rotation... and if i will use tiles, and lets say i will have let''s say 500 calls for drawprimitive, the program wont get slow?

Share this post


Link to post
Share on other sites
It depends on how you make the drawprimitive call. If you call drawprimitive 500 times every frame it will be too slow. If you create a vertex buffer and fill it with all your tile vertices and call drawprimitive once every frame then it will be extremely fast.

Share this post


Link to post
Share on other sites
it also depends on everything else, how complex the rest of your game is and stuff, and if your doing level-of-detail management - which you probably arent in this case.

but yeah, placing all vertices into a vertex buffer, even better using triangle strips, can all help in the performance area.

Share this post


Link to post
Share on other sites
I''ve done this myself so I have an idea about it. Strips won''t help you that much if you want to draw 500 quads in one DP because of the different texture coordinates for each tile. You''re best bet is to use triangle lists. Use an index buffer so you save on 2 verts. You won''t have to worry about a performance hit if all your tiles are in one texture (I have all my 16x16 tiles in one 512x512 texture). Also if all you''re tiles don''t fit into just one try to group them someway (I matched tiles into a forest texture, a town texture, a snow texture, etc).

Share this post


Link to post
Share on other sites
First of all, if you''re using DrawPrimativeUP, then performance probably isn''t your main concern. Most people only use UP for quick tests/hacks but not for all rendering. Now, 500 calls to DrawPrimative per frame doesn''t sound too bad if that''s for rendering your whole scene. Modern CPU''s/GPU''s are fast enough to handle this kind of driver abuse. If it''s all static, you''re better off using a vertex buffer though.

Share this post


Link to post
Share on other sites
~25000 DIP calls per second = 100% CPU USAGE on a 1 ghz machine. Assuming 100 frames per second (which is modest if you are just doing 2d with 3d), that is 250 calls per frame. Add on collision detection, ai, etc... You should make it one call if at all possible.

Share this post


Link to post
Share on other sites
OK, i see this alot, so I gotta ask.
Someone mentioned that if it''s static then the best bet would be the use of vertex buffers.

Is this opposed to the use of index buffers?

What if the scene if not static, meaning there is LOD management going on, so at one point there might be more vertices in a forest scene, and in another moment, there might be less vertices in the same scene. Since this is anything but static, would vertex buffers be a bad thing in particular or just an unconventional way?

I plan on using vertex buffers for my dynamic scene. then if need be, index buffers.

Share this post


Link to post
Share on other sites
First off everyone says this, vertex buffers are always a good thing.

As far as I know index buffers only save on the amount of vertices you have to send to render (can they be used another way?). For example in my last post I mentioned I use triangle lists. I can eliminate 2 vertices from my vertex buffer by instead sending 6 indices in a index buffer.

If you''re going to have a dynamic scene you should use a dynamic vertex buffer. Basically its just a vertex buffer that is setup to efficiently be locked a lot. You would want to use a static vertex buffer if once you create you''re geometry it never changes; you''d just put the vertices into the buffer and never touch them again.

What''s LOD management?

Share this post


Link to post
Share on other sites
quote:
Original post by Raloth
~25000 DIP calls per second = 100% CPU USAGE on a 1 ghz machine. Assuming 100 frames per second (which is modest if you are just doing 2d with 3d), that is 250 calls per frame. Add on collision detection, ai, etc... You should make it one call if at all possible.


1 DIP call per frame = 100% CPU USAGE on a 933 MHz machine. If you have an infinite loop like in a game, you''re going to have 100% cpu usage no matter what you do.

Share this post


Link to post
Share on other sites
quote:
Original post by glassJAw
quote:
Original post by Raloth
~25000 DIP calls per second = 100% CPU USAGE on a 1 ghz machine. Assuming 100 frames per second (which is modest if you are just doing 2d with 3d), that is 250 calls per frame. Add on collision detection, ai, etc... You should make it one call if at all possible.


1 DIP call per frame = 100% CPU USAGE on a 933 MHz machine. If you have an infinite loop like in a game, you''re going to have 100% cpu usage no matter what you do.


I don''t have the exact data offhand, but I believe he''s referring to an ATI/NVIDIA research paper on the Direct3D pipeline. He''s referring to CPU usage VS GPU usage, and you want as much GPU usage as possible. Less calls = less overhead = less cost = MORE SPEED!

---
Brent Gunning | My Site

Share this post


Link to post
Share on other sites