Jump to content
  • Advertisement
Sign in to follow this  
devronious

Advanced VBuffer?

This topic is 4462 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

I was thinking of how to optimize my performance and thought what if I created one huge vertex buffer out of all my meshes and even my sprites and then simply drew that? The only prob I see is when rendering alpha. The buffer would have to draw from front to back? The question is this, can this front to back rendering be handled by simply creating a new index buffer per frame? Or would that be bad, slow performance to lock buffer or such? Any ideas are super welcome, -Devin

Share this post


Link to post
Share on other sites
Advertisement
Try this. I am getting perfect result. and not need to drawing front to back.

lpDevice->BeginScene();

//Render first
RenderNormalobjects();

//Render last
lpDevice->SetRenderState(D3DRS_ZWRITEENABLE,false);
RenderAlphaObjects();
RenderParticles();
...
lpDevice->SetRenderState( D3DRS_ZWRITEENABLE,true);
lpDevice->EndScene()

Share this post


Link to post
Share on other sites
I've read that you want to keep your vertex buffers around 2000 vertices each. Too many vertex buffers require too much overhead. Too many vertices in a buffer is apparently slower. So you'll want to combine different objects into a single vertex buffer, but not too many. Also, you will need a vertex buffer for each vertex format.

Share this post


Link to post
Share on other sites
3ddreams,

Thanks for the alpha help. But what about alpha objects that are behind the normal objects. If the normal objects are drawn first, then won't those alpha objects draw over things they are not supposed to?

Blaze02,

Which do you think would be faster? quantity ten of 2,000 vertice buffers drawn one at a time or one 20,000 vertice buffer drawn once? I sent a post earlier and someone explained about the lag of multiple draws.

Thanks,

Devin

Share this post


Link to post
Share on other sites
Quote:
Original post by devronious
Thanks for the alpha help. But what about alpha objects that are behind the normal objects. If the normal objects are drawn first, then won't those alpha objects draw over things they are not supposed to?
3ddreams' code doesn't disable Z-Testing, only Z-Writing... so it'll still clip semi-transparent geometry to any existing geometry.

Although one thing that 3ddreams' code doesn't seem to do is sort from back-to-front. That code is similar to what I've used for particle systems before and it's worked great, but for more complex semi-transparent geometry I've got odd artifacts by not sorting things properly. YMMV.

Quote:
Original post by devronious
I sent a post earlier and someone explained about the lag of multiple draws.
Pre-D3D10 the context switch incurred by Draw**() calls does mean that a high number of them can mean you end up wasting much of your time. However, there is always a sweet-spot between 1 huge buffer and many small buffers - there isn't really a one-size-fits-all answer. If you dig around on the ATI and Nvidia website they tend to have presentations/whitepapers on this sort of thing. I know there was an excel spreadsheet on the Nvidia site that had results of different vertex and batch sizes - and you can use that to try and guage the optimal batch size.

hth
Jack

Share this post


Link to post
Share on other sites
Jolly,

Thanks I got zwriting confused with zbufferenable. That makes sense.

Also read about D3D10 instancing when looking up batching. Looks pretty powerful. Perhaps I'll migrate into D3D10 now before I complete my engine. Is D3D10 ready to go?

-Devin

Share this post


Link to post
Share on other sites
Quote:
Original post by devronious
Is D3D10 ready to go?
Not really. There aren't any Direct3D 10 cards on the market yet, and D3D10 isn't backwards compatible (Meaning you need a D3D10 card to use it, you can't use it on an ATi X1900 or anything). That's actually a good thing though, since a lot of the crap has been dropped. Still, you can only use the reference rasterizer till D3D10 cards come out.

It's almost certainly better to stick with D3D9 now, unless you've just started the engine and you expect it to be in development for a long time.

Share this post


Link to post
Share on other sites
Steve's covered the main points... but there is also the other added factor (if you weren't aware) that D3D10 is Windows Vista only - so for now you'll need to be an MSDN subscriber or on the Vista beta program...

Developing anything beyond samples via the reference rasterizer is a challenge in itself - typically it'll require some degree of automation so you can leave it to effectively batch-render a number of frames and then play it back as a movie...

hth
Jack

Share this post


Link to post
Share on other sites
Cool, I guess I'll wait with anticipation, but definately don't want to do something that cards don't support at the moment!

Thanks Guys,

I think I'll build a vertex buffer class to automatically organize my meshes and sprites for me.

Thanks,

Devin

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.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!