Jump to content
  • Advertisement
Sign in to follow this  
littlekid

Method to render the BSP in directx

This topic is 4818 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

Hi I am new to using directx to render a BSP tree. This is what i did. Before Game Loop: 1. I created the BSP tree using the index as I thought creating many duplicate vertex would cost alot of memeory. 2. After the BSP tree is created, i load the vertex buffer with the vertex. During Game Loop: 1. I check whether the eye is infront or behind the splitting plane then i tranverse down the tree pushing the index at the nodes into a - vector<WORD> index. 2. After the tranversal is done, I create the index buffer using the vector<WORD> index, then i draw the scence. Next I destroy the index buffer and prepare for the next loop. I am rendering using default_interval. Is this the correct method? I rendered the mesh car.x from the Directx SDK sample mesh and the fps was at 12-15. Is this normal or am i doing it wrongly?

Share this post


Link to post
Share on other sites
Advertisement
From your description, I'd be saying it's your usage of std::vector and IB's that's killing you.

Creating/recreating resources inside a game loop is never a good idea, sometimes you have no choice, but for the most part you can (and should) avoid it.

The simple thing here is to change your index buffer so that it's dynamic (D3DUSAGE_DYNAMIC iirc) and of a size that you think can store all your data (usually making it a bit bigger is okay) and then use the Lock() mechanisms to just overwrite data each frame.

overwriting the data each frame is still not necessarily the quickest option, but it'll definitely be faster than what you've currently got. If you can, try and "dump" your data from system memory to the IB instead of copying per-element in a loop.

You might well find that the greatest improvement you can make is going to be a change of architecture (macro optimization) rather than little tweaks (micro optimization). I can't really give you an answer to this as such, but break out some profiling tools (e.g. PIX for windows) and maybe pen/paper to draw out execution paths...

For example, in my quadtree implementation some years back, I found that storing lots and lots of duplicate index buffers chewed up an extra 500-600kb of storage, but gave me a lot more speed (less resource switching/modifying). For modern video cards, that extra storage is really nothing to worry about [smile]

This change was more of a macro optimization as I changed the fundamental algorithm/process for rendering, rather than trying to optimize each-and-every call/operation...

hth
Jack

Share this post


Link to post
Share on other sites
Thanks for the answer. Using D3DUSAGE_DYNAMIC stablise the fps at certain numbers which varies for different mesh. I suspect the low fps in thoes high index mesh is due to the extensive time take to tranverse the depth of the tree.

Is there any way to speed up the tree tranvsal? My current method is to use recursion to travel down the tree. Is using a stack to tranverse the tree faster?

20955 index -> 29-31 fps?
Is there any way to increase the fps?

Could syou uggest some macro optimization for a bsp tree? Currently my bsp is the same as the one in this article from gamedev:

http://www.gamedev.net/reference/articles/article657.asp

Share this post


Link to post
Share on other sites
Quote:
Original post by littlekid
Thanks for the answer. Using D3DUSAGE_DYNAMIC stablise the fps at certain numbers which varies for different mesh. I suspect the low fps in thoes high index mesh is due to the extensive time take to tranverse the depth of the tree.

You need to run some profiling - guessing where you're losing time is like walking in the countryside without a map [wink]

Quote:
Original post by littlekid
Is there any way to speed up the tree tranvsal? My current method is to use recursion to travel down the tree. Is using a stack to tranverse the tree faster?

Difficult to say, until you have some precise instrumentation you're not going to know for sure. Usually for things like trees, reducing the number of nodes it checks, and restructuring it is the best bet...

Quote:
Original post by littlekid
Could syou uggest some macro optimization for a bsp tree? Currently my bsp is the same as the one in this article from gamedev:

http://www.gamedev.net/reference/articles/article657.asp

I've never had any need to implement a BSP tree in my software, so I'm not the best person to answer this.

Maybe someone else can post some ideas here, failing that you could try the people in the Graphics Programming & Theory forum.

hth
Jack

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!